From 9ac34f8690b9b19cc2c6c8009febc3a4c30535cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Tue, 31 Mar 2026 15:56:57 +0200 Subject: [PATCH 1/9] :coffin: remove deprecated products --- docs/code_samples/bank_account_details_v1.txt | 41 -- docs/code_samples/bank_check_v1.txt | 41 -- docs/code_samples/bill_of_lading_v1_async.txt | 41 -- docs/code_samples/business_card_v1_async.txt | 41 -- docs/code_samples/custom_v1.txt | 48 -- docs/code_samples/delivery_notes_v1_async.txt | 41 -- .../code_samples/energy_bill_fra_v1_async.txt | 41 -- .../french_healthcard_v1_async.txt | 41 -- .../code_samples/nutrition_facts_v1_async.txt | 41 -- docs/code_samples/payslip_fra_v3_async.txt | 41 -- docs/code_samples/resume_v1_async.txt | 41 -- .../us_healthcare_cards_v1_async.txt | 41 -- docs/code_samples/us_mail_v3_async.txt | 41 -- .../java/com/mindee/CommandLineInterface.java | 36 -- src/main/java/com/mindee/MindeeClient.java | 149 ++--- .../cli/CommandLineInterfaceProducts.java | 137 +--- .../parsing/custom/ClassificationField.java | 32 - ...ustomV1DocumentPredictionDeserializer.java | 57 -- .../com/mindee/parsing/custom/ListField.java | 73 --- .../mindee/parsing/custom/ListFieldValue.java | 55 -- .../parsing/custom/lineitems/Anchor.java | 28 - .../mindee/parsing/custom/lineitems/Line.java | 72 --- .../custom/lineitems/LineGenerator.java | 73 --- .../parsing/custom/lineitems/LineItems.java | 22 - .../custom/lineitems/LineItemsGenerator.java | 94 --- .../custom/lineitems/PreparedLines.java | 21 - .../product/billoflading/BillOfLadingV1.java | 15 - .../billoflading/BillOfLadingV1Carrier.java | 67 -- .../BillOfLadingV1CarrierItem.java | 106 ---- .../billoflading/BillOfLadingV1Consignee.java | 75 --- .../billoflading/BillOfLadingV1Document.java | 126 ---- .../BillOfLadingV1NotifyParty.java | 75 --- .../billoflading/BillOfLadingV1Shipper.java | 75 --- .../product/businesscard/BusinessCardV1.java | 15 - .../businesscard/BusinessCardV1Document.java | 109 ---- .../com/mindee/product/custom/CustomV1.java | 14 - .../product/custom/CustomV1Document.java | 59 -- .../mindee/product/custom/CustomV1Page.java | 32 - .../product/deliverynote/DeliveryNoteV1.java | 15 - .../deliverynote/DeliveryNoteV1Document.java | 80 --- .../BankAccountDetailsV1.java | 16 - .../BankAccountDetailsV1Document.java | 48 -- .../product/fr/energybill/EnergyBillV1.java | 15 - .../fr/energybill/EnergyBillV1Document.java | 185 ------ .../EnergyBillV1EnergyConsumer.java | 56 -- .../EnergyBillV1EnergySupplier.java | 56 -- .../energybill/EnergyBillV1EnergyUsage.java | 126 ---- .../energybill/EnergyBillV1MeterDetail.java | 66 -- .../energybill/EnergyBillV1Subscription.java | 106 ---- .../EnergyBillV1TaxesAndContribution.java | 106 ---- .../product/fr/healthcard/HealthCardV1.java | 15 - .../fr/healthcard/HealthCardV1Document.java | 61 -- .../mindee/product/fr/payslip/PayslipV3.java | 15 - .../payslip/PayslipV3BankAccountDetail.java | 66 -- .../product/fr/payslip/PayslipV3Document.java | 120 ---- .../product/fr/payslip/PayslipV3Employee.java | 104 ---- .../product/fr/payslip/PayslipV3Employer.java | 102 --- .../fr/payslip/PayslipV3Employment.java | 103 --- .../fr/payslip/PayslipV3PaidTimeOff.java | 96 --- .../fr/payslip/PayslipV3PayDetail.java | 131 ---- .../fr/payslip/PayslipV3PayPeriod.java | 84 --- .../fr/payslip/PayslipV3SalaryDetail.java | 96 --- .../NutritionFactsLabelV1.java | 16 - .../NutritionFactsLabelV1AddedSugar.java | 64 -- .../NutritionFactsLabelV1Calorie.java | 64 -- .../NutritionFactsLabelV1Cholesterol.java | 64 -- .../NutritionFactsLabelV1DietaryFiber.java | 64 -- .../NutritionFactsLabelV1Document.java | 145 ----- .../NutritionFactsLabelV1Nutrient.java | 96 --- .../NutritionFactsLabelV1Protein.java | 64 -- .../NutritionFactsLabelV1SaturatedFat.java | 64 -- .../NutritionFactsLabelV1ServingSize.java | 56 -- .../NutritionFactsLabelV1Sodium.java | 75 --- ...utritionFactsLabelV1TotalCarbohydrate.java | 64 -- .../NutritionFactsLabelV1TotalFat.java | 64 -- .../NutritionFactsLabelV1TotalSugar.java | 64 -- .../NutritionFactsLabelV1TransFat.java | 64 -- .../com/mindee/product/resume/ResumeV1.java | 15 - .../product/resume/ResumeV1Certificate.java | 86 --- .../product/resume/ResumeV1Document.java | 233 ------- .../product/resume/ResumeV1Education.java | 116 ---- .../product/resume/ResumeV1Language.java | 65 -- .../ResumeV1ProfessionalExperience.java | 136 ---- .../resume/ResumeV1SocialNetworksUrl.java | 65 -- .../product/us/bankcheck/BankCheckV1.java | 15 - .../us/bankcheck/BankCheckV1Document.java | 76 --- .../product/us/bankcheck/BankCheckV1Page.java | 48 -- .../us/healthcarecard/HealthcareCardV1.java | 16 - .../healthcarecard/HealthcareCardV1Copay.java | 65 -- .../HealthcareCardV1Document.java | 141 ----- .../mindee/product/us/usmail/UsMailV3.java | 15 - .../product/us/usmail/UsMailV3Document.java | 88 --- .../us/usmail/UsMailV3RecipientAddress.java | 128 ---- .../us/usmail/UsMailV3SenderAddress.java | 84 --- .../java/com/mindee/MindeeClientTest.java | 83 --- .../custom/lineitems/FakeListField.java | 589 ------------------ .../custom/lineitems/LineGeneratorTest.java | 84 --- .../billoflading/BillOfLadingV1Test.java | 72 --- .../businesscard/BusinessCardV1Test.java | 61 -- .../mindee/product/custom/CustomV1Test.java | 94 --- .../custom/CustomV1WithLineItemsTest.java | 74 --- .../deliverynote/DeliveryNoteV1Test.java | 57 -- .../BankAccountDetailsV1Test.java | 58 -- .../fr/energybill/EnergyBillV1Test.java | 68 -- .../fr/healthcard/HealthCardV1Test.java | 56 -- .../product/fr/payslip/PayslipV3Test.java | 91 --- .../NutritionFactsLabelV1Test.java | 91 --- .../mindee/product/resume/ResumeV1Test.java | 68 -- .../product/us/bankcheck/BankCheckV1Test.java | 74 --- .../healthcarecard/HealthcareCardV1Test.java | 66 -- .../product/us/usmail/UsMailV3Test.java | 59 -- 111 files changed, 40 insertions(+), 8150 deletions(-) delete mode 100644 docs/code_samples/bank_account_details_v1.txt delete mode 100644 docs/code_samples/bank_check_v1.txt delete mode 100644 docs/code_samples/bill_of_lading_v1_async.txt delete mode 100644 docs/code_samples/business_card_v1_async.txt delete mode 100644 docs/code_samples/custom_v1.txt delete mode 100644 docs/code_samples/delivery_notes_v1_async.txt delete mode 100644 docs/code_samples/energy_bill_fra_v1_async.txt delete mode 100644 docs/code_samples/french_healthcard_v1_async.txt delete mode 100644 docs/code_samples/nutrition_facts_v1_async.txt delete mode 100644 docs/code_samples/payslip_fra_v3_async.txt delete mode 100644 docs/code_samples/resume_v1_async.txt delete mode 100644 docs/code_samples/us_healthcare_cards_v1_async.txt delete mode 100644 docs/code_samples/us_mail_v3_async.txt delete mode 100644 src/main/java/com/mindee/parsing/custom/ClassificationField.java delete mode 100644 src/main/java/com/mindee/parsing/custom/CustomV1DocumentPredictionDeserializer.java delete mode 100644 src/main/java/com/mindee/parsing/custom/ListField.java delete mode 100644 src/main/java/com/mindee/parsing/custom/ListFieldValue.java delete mode 100644 src/main/java/com/mindee/parsing/custom/lineitems/Anchor.java delete mode 100644 src/main/java/com/mindee/parsing/custom/lineitems/Line.java delete mode 100644 src/main/java/com/mindee/parsing/custom/lineitems/LineGenerator.java delete mode 100644 src/main/java/com/mindee/parsing/custom/lineitems/LineItems.java delete mode 100644 src/main/java/com/mindee/parsing/custom/lineitems/LineItemsGenerator.java delete mode 100644 src/main/java/com/mindee/parsing/custom/lineitems/PreparedLines.java delete mode 100644 src/main/java/com/mindee/product/billoflading/BillOfLadingV1.java delete mode 100644 src/main/java/com/mindee/product/billoflading/BillOfLadingV1Carrier.java delete mode 100644 src/main/java/com/mindee/product/billoflading/BillOfLadingV1CarrierItem.java delete mode 100644 src/main/java/com/mindee/product/billoflading/BillOfLadingV1Consignee.java delete mode 100644 src/main/java/com/mindee/product/billoflading/BillOfLadingV1Document.java delete mode 100644 src/main/java/com/mindee/product/billoflading/BillOfLadingV1NotifyParty.java delete mode 100644 src/main/java/com/mindee/product/billoflading/BillOfLadingV1Shipper.java delete mode 100644 src/main/java/com/mindee/product/businesscard/BusinessCardV1.java delete mode 100644 src/main/java/com/mindee/product/businesscard/BusinessCardV1Document.java delete mode 100644 src/main/java/com/mindee/product/custom/CustomV1.java delete mode 100644 src/main/java/com/mindee/product/custom/CustomV1Document.java delete mode 100644 src/main/java/com/mindee/product/custom/CustomV1Page.java delete mode 100644 src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1.java delete mode 100644 src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1Document.java delete mode 100644 src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1.java delete mode 100644 src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1Document.java delete mode 100644 src/main/java/com/mindee/product/fr/energybill/EnergyBillV1.java delete mode 100644 src/main/java/com/mindee/product/fr/energybill/EnergyBillV1Document.java delete mode 100644 src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergyConsumer.java delete mode 100644 src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergySupplier.java delete mode 100644 src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergyUsage.java delete mode 100644 src/main/java/com/mindee/product/fr/energybill/EnergyBillV1MeterDetail.java delete mode 100644 src/main/java/com/mindee/product/fr/energybill/EnergyBillV1Subscription.java delete mode 100644 src/main/java/com/mindee/product/fr/energybill/EnergyBillV1TaxesAndContribution.java delete mode 100644 src/main/java/com/mindee/product/fr/healthcard/HealthCardV1.java delete mode 100644 src/main/java/com/mindee/product/fr/healthcard/HealthCardV1Document.java delete mode 100644 src/main/java/com/mindee/product/fr/payslip/PayslipV3.java delete mode 100644 src/main/java/com/mindee/product/fr/payslip/PayslipV3BankAccountDetail.java delete mode 100644 src/main/java/com/mindee/product/fr/payslip/PayslipV3Document.java delete mode 100644 src/main/java/com/mindee/product/fr/payslip/PayslipV3Employee.java delete mode 100644 src/main/java/com/mindee/product/fr/payslip/PayslipV3Employer.java delete mode 100644 src/main/java/com/mindee/product/fr/payslip/PayslipV3Employment.java delete mode 100644 src/main/java/com/mindee/product/fr/payslip/PayslipV3PaidTimeOff.java delete mode 100644 src/main/java/com/mindee/product/fr/payslip/PayslipV3PayDetail.java delete mode 100644 src/main/java/com/mindee/product/fr/payslip/PayslipV3PayPeriod.java delete mode 100644 src/main/java/com/mindee/product/fr/payslip/PayslipV3SalaryDetail.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1AddedSugar.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Calorie.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Cholesterol.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1DietaryFiber.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Document.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Nutrient.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Protein.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1SaturatedFat.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1ServingSize.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Sodium.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalCarbohydrate.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalFat.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalSugar.java delete mode 100644 src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TransFat.java delete mode 100644 src/main/java/com/mindee/product/resume/ResumeV1.java delete mode 100644 src/main/java/com/mindee/product/resume/ResumeV1Certificate.java delete mode 100644 src/main/java/com/mindee/product/resume/ResumeV1Document.java delete mode 100644 src/main/java/com/mindee/product/resume/ResumeV1Education.java delete mode 100644 src/main/java/com/mindee/product/resume/ResumeV1Language.java delete mode 100644 src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java delete mode 100644 src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java delete mode 100644 src/main/java/com/mindee/product/us/bankcheck/BankCheckV1.java delete mode 100644 src/main/java/com/mindee/product/us/bankcheck/BankCheckV1Document.java delete mode 100644 src/main/java/com/mindee/product/us/bankcheck/BankCheckV1Page.java delete mode 100644 src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1.java delete mode 100644 src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Copay.java delete mode 100644 src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java delete mode 100644 src/main/java/com/mindee/product/us/usmail/UsMailV3.java delete mode 100644 src/main/java/com/mindee/product/us/usmail/UsMailV3Document.java delete mode 100644 src/main/java/com/mindee/product/us/usmail/UsMailV3RecipientAddress.java delete mode 100644 src/main/java/com/mindee/product/us/usmail/UsMailV3SenderAddress.java delete mode 100644 src/test/java/com/mindee/parsing/custom/lineitems/FakeListField.java delete mode 100644 src/test/java/com/mindee/parsing/custom/lineitems/LineGeneratorTest.java delete mode 100644 src/test/java/com/mindee/product/billoflading/BillOfLadingV1Test.java delete mode 100644 src/test/java/com/mindee/product/businesscard/BusinessCardV1Test.java delete mode 100644 src/test/java/com/mindee/product/custom/CustomV1Test.java delete mode 100644 src/test/java/com/mindee/product/custom/CustomV1WithLineItemsTest.java delete mode 100644 src/test/java/com/mindee/product/deliverynote/DeliveryNoteV1Test.java delete mode 100644 src/test/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1Test.java delete mode 100644 src/test/java/com/mindee/product/fr/energybill/EnergyBillV1Test.java delete mode 100644 src/test/java/com/mindee/product/fr/healthcard/HealthCardV1Test.java delete mode 100644 src/test/java/com/mindee/product/fr/payslip/PayslipV3Test.java delete mode 100644 src/test/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Test.java delete mode 100644 src/test/java/com/mindee/product/resume/ResumeV1Test.java delete mode 100644 src/test/java/com/mindee/product/us/bankcheck/BankCheckV1Test.java delete mode 100644 src/test/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Test.java delete mode 100644 src/test/java/com/mindee/product/us/usmail/UsMailV3Test.java diff --git a/docs/code_samples/bank_account_details_v1.txt b/docs/code_samples/bank_account_details_v1.txt deleted file mode 100644 index c92adf1ca..000000000 --- a/docs/code_samples/bank_account_details_v1.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.fr.bankaccountdetails.BankAccountDetailsV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); - - // Parse the file - PredictResponse response = mindeeClient.parse( - BankAccountDetailsV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocument().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/bank_check_v1.txt b/docs/code_samples/bank_check_v1.txt deleted file mode 100644 index 1823ad820..000000000 --- a/docs/code_samples/bank_check_v1.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.us.bankcheck.BankCheckV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); - - // Parse the file - PredictResponse response = mindeeClient.parse( - BankCheckV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocument().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/bill_of_lading_v1_async.txt b/docs/code_samples/bill_of_lading_v1_async.txt deleted file mode 100644 index 4c77c884b..000000000 --- a/docs/code_samples/bill_of_lading_v1_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.billoflading.BillOfLadingV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException, InterruptedException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); - - // Parse the file asynchronously - AsyncPredictResponse response = mindeeClient.enqueueAndParse( - BillOfLadingV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocumentObj().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocumentObj().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/business_card_v1_async.txt b/docs/code_samples/business_card_v1_async.txt deleted file mode 100644 index c92559522..000000000 --- a/docs/code_samples/business_card_v1_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.businesscard.BusinessCardV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException, InterruptedException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); - - // Parse the file asynchronously - AsyncPredictResponse response = mindeeClient.enqueueAndParse( - BusinessCardV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocumentObj().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocumentObj().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/custom_v1.txt b/docs/code_samples/custom_v1.txt deleted file mode 100644 index 306ae8da8..000000000 --- a/docs/code_samples/custom_v1.txt +++ /dev/null @@ -1,48 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.custom.CustomV1; -import com.mindee.http.Endpoint; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); - - // Configure the endpoint - Endpoint endpoint = new Endpoint( - "my-endpoint", - "my-account" - ); - - // Parse the file - PredictResponse response = mindeeClient.parse( - inputSource, - endpoint - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocument().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/delivery_notes_v1_async.txt b/docs/code_samples/delivery_notes_v1_async.txt deleted file mode 100644 index 14ce28dab..000000000 --- a/docs/code_samples/delivery_notes_v1_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.deliverynote.DeliveryNoteV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException, InterruptedException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); - - // Parse the file asynchronously - AsyncPredictResponse response = mindeeClient.enqueueAndParse( - DeliveryNoteV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocumentObj().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocumentObj().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/energy_bill_fra_v1_async.txt b/docs/code_samples/energy_bill_fra_v1_async.txt deleted file mode 100644 index dbcc08313..000000000 --- a/docs/code_samples/energy_bill_fra_v1_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.fr.energybill.EnergyBillV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException, InterruptedException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); - - // Parse the file asynchronously - AsyncPredictResponse response = mindeeClient.enqueueAndParse( - EnergyBillV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocumentObj().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocumentObj().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/french_healthcard_v1_async.txt b/docs/code_samples/french_healthcard_v1_async.txt deleted file mode 100644 index 2f009c44d..000000000 --- a/docs/code_samples/french_healthcard_v1_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.fr.healthcard.HealthCardV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException, InterruptedException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); - - // Parse the file asynchronously - AsyncPredictResponse response = mindeeClient.enqueueAndParse( - HealthCardV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocumentObj().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocumentObj().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/nutrition_facts_v1_async.txt b/docs/code_samples/nutrition_facts_v1_async.txt deleted file mode 100644 index 3320d196a..000000000 --- a/docs/code_samples/nutrition_facts_v1_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.nutritionfactslabel.NutritionFactsLabelV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException, InterruptedException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); - - // Parse the file asynchronously - AsyncPredictResponse response = mindeeClient.enqueueAndParse( - NutritionFactsLabelV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocumentObj().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocumentObj().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/payslip_fra_v3_async.txt b/docs/code_samples/payslip_fra_v3_async.txt deleted file mode 100644 index ee10e4705..000000000 --- a/docs/code_samples/payslip_fra_v3_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.fr.payslip.PayslipV3; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException, InterruptedException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); - - // Parse the file asynchronously - AsyncPredictResponse response = mindeeClient.enqueueAndParse( - PayslipV3.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocumentObj().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocumentObj().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/resume_v1_async.txt b/docs/code_samples/resume_v1_async.txt deleted file mode 100644 index 49eb98883..000000000 --- a/docs/code_samples/resume_v1_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.resume.ResumeV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException, InterruptedException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); - - // Parse the file asynchronously - AsyncPredictResponse response = mindeeClient.enqueueAndParse( - ResumeV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocumentObj().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocumentObj().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/us_healthcare_cards_v1_async.txt b/docs/code_samples/us_healthcare_cards_v1_async.txt deleted file mode 100644 index 9ac40e5e6..000000000 --- a/docs/code_samples/us_healthcare_cards_v1_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.us.healthcarecard.HealthcareCardV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException, InterruptedException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); - - // Parse the file asynchronously - AsyncPredictResponse response = mindeeClient.enqueueAndParse( - HealthcareCardV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocumentObj().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocumentObj().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/us_mail_v3_async.txt b/docs/code_samples/us_mail_v3_async.txt deleted file mode 100644 index 18afe0d36..000000000 --- a/docs/code_samples/us_mail_v3_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.us.usmail.UsMailV3; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClientV1 { - - public static void main(String[] args) throws IOException, InterruptedException { - String apiKey = "my-api-key"; - String filePath = "/path/to/the/file.ext"; - - // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); - - // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); - - // Parse the file asynchronously - AsyncPredictResponse response = mindeeClient.enqueueAndParse( - UsMailV3.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocumentObj().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocumentObj().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/src/main/java/com/mindee/CommandLineInterface.java b/src/main/java/com/mindee/CommandLineInterface.java index 3e19341ba..2a02648a9 100644 --- a/src/main/java/com/mindee/CommandLineInterface.java +++ b/src/main/java/com/mindee/CommandLineInterface.java @@ -10,7 +10,6 @@ import com.mindee.parsing.common.Inference; import com.mindee.parsing.common.PredictResponse; import com.mindee.parsing.common.ocr.Ocr; -import com.mindee.product.custom.CustomV1; import com.mindee.product.generated.GeneratedV1; import java.io.File; import java.io.IOException; @@ -149,41 +148,6 @@ public Integer call() throws Exception { } } - @Command( - name = "custom", - description = "Invokes a Custom API (API Builder only, use 'generated' for regular custom APIs)" - ) - void customMethod( - @Option( - names = { "-a", "--account" }, - scope = ScopeType.LOCAL, - required = true, - paramLabel = "accountName", - description = "The name of the account" - ) String accountName, - @Option( - names = { "-e", "--endpointName" }, - scope = ScopeType.LOCAL, - required = true, - paramLabel = "endpointName", - description = "The name of the endpoint" - ) String endpointName, - @Parameters(index = "0", scope = ScopeType.LOCAL, paramLabel = "") File file - ) throws IOException { - - MindeeClient mindeeClient = new MindeeClient(apiKey); - - PredictResponse document; - Endpoint endpoint = new Endpoint(endpointName, accountName, "1"); - - if (cutDoc) { - document = mindeeClient.parse(new LocalInputSource(file), endpoint, getDefaultPageOptions()); - } else { - document = mindeeClient.parse(new LocalInputSource(file), endpoint); - } - System.out.println(document.toString()); - } - @Command(name = "generated", description = "Invokes a Generated API") void generatedMethod( @Option( diff --git a/src/main/java/com/mindee/MindeeClient.java b/src/main/java/com/mindee/MindeeClient.java index 32d961ceb..c4b96e093 100644 --- a/src/main/java/com/mindee/MindeeClient.java +++ b/src/main/java/com/mindee/MindeeClient.java @@ -17,7 +17,6 @@ import com.mindee.pdf.PdfBoxApi; import com.mindee.pdf.PdfOperation; import com.mindee.pdf.SplitQuery; -import com.mindee.product.custom.CustomV1; import com.mindee.product.generated.GeneratedV1; import java.io.IOException; import java.net.URL; @@ -61,7 +60,7 @@ public MindeeClient(MindeeApi mindeeApi) { /** * Create a MindeeClient. - * + * * @param pdfOperation The PdfOperation implementation to be used by the created MindeeClient. * @param mindeeApi The MindeeApi implementation to be used by the created MindeeClient. */ @@ -82,7 +81,7 @@ private static MindeeApi createDefaultApi(String apiKey) { /** * Parse a document from an async queue. - * + * * @param Type of inference. * @param type Type of inference; * @param jobId ID of the job. @@ -94,7 +93,7 @@ public AsyncPredictResponse parseQueued(Class type, /** * Send a local file to an async queue. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -118,7 +117,7 @@ public AsyncPredictResponse enqueue( /** * Retrieves the file after applying page operations to it. - * + * * @param localInputSource Local input source to apply operations to. * @param pageOptions Options to apply. * @return A byte array of the file after applying page operations. @@ -141,7 +140,7 @@ protected byte[] getSplitFile( /** * Send a local file to an async queue. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -169,7 +168,7 @@ public AsyncPredictResponse enqueue( /** * Send a local file to an async queue. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -195,7 +194,7 @@ public AsyncPredictResponse enqueue( /** * Send a remote file to an async queue. - * + * * @param Type of inference. * @param type Type of inference. * @param sourceUrl A URL to a remote file. @@ -212,7 +211,7 @@ public AsyncPredictResponse enqueue( /** * Send a remote file to an async queue. - * + * * @param Type of inference. * @param type Type of inference. * @param sourceUrl A URL to a remote file. @@ -249,7 +248,7 @@ private AsyncPredictResponse enqueue( /** * Send a local file to an async queue, poll, and parse when complete. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -275,7 +274,7 @@ public AsyncPredictResponse enqueueAndParse( /** * Send a local file to an async queue, poll, and parse when complete. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -303,7 +302,7 @@ public AsyncPredictResponse enqueueAndParse( /** * Send a local file to an async queue, poll, and parse when complete. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -335,7 +334,7 @@ public AsyncPredictResponse enqueueAndParse( /** * Send a local file to an async queue, poll, and parse when complete. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -365,7 +364,7 @@ public AsyncPredictResponse enqueueAndParse( /** * Send a local file to an async queue, poll, and parse when complete. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -393,7 +392,7 @@ public AsyncPredictResponse enqueueAndParse( /** * Send a remote file to an async queue, poll, and parse when complete. - * + * * @param Type of inference. * @param type Type of inference. * @param sourceUrl A URL to a remote file. @@ -411,7 +410,7 @@ public AsyncPredictResponse enqueueAndParse( /** * Validate async polling options. - * + * * @param pollingOptions Options for async call parameters * @throws MindeeException Throws if settings aren't set properly. */ @@ -484,7 +483,7 @@ private AsyncPredictResponse enqueueAndParse( /** * Send a local file to a workflow execution. - * + * * @param workflowId ID of the workflow to send the document to. * @param localInputSource A local input source file. * @param workflowOptions Options for the workflow execution. @@ -511,7 +510,7 @@ public WorkflowResponse executeWorkflow( /** * Send a local file to a workflow execution. - * + * * @param workflowId ID of the workflow to send the document to. * @param localInputSource A local input source file. * @return A workflow response. @@ -536,7 +535,7 @@ public WorkflowResponse executeWorkflow( /** * Send a local file to a Standard prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -560,7 +559,7 @@ public PredictResponse parse( /** * Send a local file to a Standard prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -586,7 +585,7 @@ public PredictResponse parse( /** * Send a local file to a Standard prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -612,7 +611,7 @@ public PredictResponse parse( /** * Send a local file to a Standard prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -640,7 +639,7 @@ public PredictResponse parse( /** * Send a remote file to a Standard prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param urlInputSource A URL to a remote file. @@ -657,7 +656,7 @@ public PredictResponse parse( /** * Send a remote file to a Standard prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param urlInputSource A URL to a remote file. @@ -692,79 +691,9 @@ private PredictResponse parse( return this.mindeeApi.predictPost(type, endpoint, params); } - /** - * Send a local file to a Custom prediction API and parse the results. - * - * @param localInputSource A local input source file. - * @param endpoint Custom endpoint to send the document to. - * @return an instance of {@link PredictResponse}. - * @throws IOException Throws if the file can't be accessed. - */ - public PredictResponse parse( - LocalInputSource localInputSource, - Endpoint endpoint - ) throws IOException { - return this.parse(localInputSource.getFile(), localInputSource.getFilename(), endpoint, null); - } - - /** - * Send a local file to a Custom prediction API and parse the results. - * - * @param localInputSource A local input source file. - * @param endpoint Custom endpoint to send the document to. - * @param pageOptions Page options for PDF documents. - * @return an instance of {@link PredictResponse}. - * @throws IOException Throws if the file can't be accessed. - */ - public PredictResponse parse( - LocalInputSource localInputSource, - Endpoint endpoint, - PageOptions pageOptions - ) throws IOException { - return this - .parse( - getSplitFile(localInputSource, pageOptions), - localInputSource.getFilename(), - endpoint, - null - ); - } - - /** - * Send a remote file to a Custom prediction API and parse the results. - * - * @param documentUrl A URL to a remote file. - * @param endpoint Custom endpoint to send the document to. - * @return an instance of {@link PredictResponse}. - * @throws IOException Throws if the file can't be accessed. - */ - public PredictResponse parse(URL documentUrl, Endpoint endpoint) throws IOException { - InputSourceUtils.validateUrl(documentUrl); - return this.parse(null, null, endpoint, documentUrl); - } - - private PredictResponse parse( - byte[] file, - String filename, - Endpoint endpoint, - URL urlInputSource - ) throws IOException { - return this.mindeeApi - .predictPost( - CustomV1.class, - endpoint, - RequestParameters - .builder() - .file(file) - .fileName(filename) - .urlInputSource(urlInputSource) - .build() - ); - } - /** * Send a local file to a Generated prediction async API queue. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -790,7 +719,7 @@ public AsyncPredictResponse enqueue( /** * Send a local file to a Generated prediction async API queue. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -820,7 +749,7 @@ public AsyncPredictResponse enqueue( /** * Send a remote file to a Generated prediction async API queue. - * + * * @param Type of inference. * @param type Type of inference. * @param endpoint Custom endpoint to send the document to. @@ -839,7 +768,7 @@ public AsyncPredictResponse enqueue( /** * Send a remote file to a Generated prediction async API queue. - * + * * @param Type of inference. * @param type Type of inference. * @param sourceUrl A URL to a remote file. @@ -860,7 +789,7 @@ public AsyncPredictResponse enqueue( /** * Send a local file to a Generated prediction API async queue, poll, and parse when complete. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -888,7 +817,7 @@ public AsyncPredictResponse enqueueAndParse( /** * Send a local file to a Generated prediction API async queue, poll, and parse when complete. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -918,7 +847,7 @@ public AsyncPredictResponse enqueueAndParse( /** * Send a local file to a Generated prediction API async queue, poll, and parse when complete. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -952,7 +881,7 @@ public AsyncPredictResponse enqueueAndParse( /** * Send a remote file to a Generated prediction API async queue, poll, and parse when complete. - * + * * @param Type of inference. * @param type Type of inference. * @param endpoint Custom endpoint to send the document to. @@ -972,7 +901,7 @@ public AsyncPredictResponse enqueueAndParse( /** * Send a local file to a Generated prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -998,7 +927,7 @@ public PredictResponse parse( /** * Send a local file to a Generated prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -1026,7 +955,7 @@ public PredictResponse parse( /** * Send a local file to a Generated prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -1054,7 +983,7 @@ public PredictResponse parse( /** * Send a local file to a Standard prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param localInputSource A local input source file. @@ -1084,7 +1013,7 @@ public PredictResponse parse( /** * Send a remote file to a Generated prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param endpoint Custom endpoint to send the document to. @@ -1103,7 +1032,7 @@ public PredictResponse parse( /** * Send a remote file to a Generated prediction API and parse the results. - * + * * @param Type of inference. * @param type Type of inference. * @param documentUrl A URL to a remote file. @@ -1124,7 +1053,7 @@ public PredictResponse parse( /** * Parse a document from a Generated prediction API async queue. - * + * * @param Type of inference. * @param type Type of inference. * @param endpoint Custom endpoint to send the document to. @@ -1143,7 +1072,7 @@ public AsyncPredictResponse parseQueued( * Load a local prediction. * Typically used when wanting to load from a webhook callback. * However, any kind of Mindee response may be loaded. - * + * * @param Type of inference. * @param type Type of inference. * @param localResponse A loaded local response. diff --git a/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java b/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java index ab7d4e8d4..813d1ff4e 100644 --- a/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java +++ b/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java @@ -1,30 +1,19 @@ package com.mindee.cli; import com.mindee.product.barcodereader.BarcodeReaderV1; -import com.mindee.product.billoflading.BillOfLadingV1; -import com.mindee.product.businesscard.BusinessCardV1; import com.mindee.product.cropper.CropperV1; -import com.mindee.product.deliverynote.DeliveryNoteV1; import com.mindee.product.driverlicense.DriverLicenseV1; import com.mindee.product.financialdocument.FinancialDocumentV1; import com.mindee.product.fr.bankaccountdetails.BankAccountDetailsV2; import com.mindee.product.fr.cartegrise.CarteGriseV1; -import com.mindee.product.fr.energybill.EnergyBillV1; -import com.mindee.product.fr.healthcard.HealthCardV1; import com.mindee.product.fr.idcard.IdCardV2; -import com.mindee.product.fr.payslip.PayslipV3; import com.mindee.product.ind.indianpassport.IndianPassportV1; import com.mindee.product.internationalid.InternationalIdV2; import com.mindee.product.invoice.InvoiceV4; import com.mindee.product.invoicesplitter.InvoiceSplitterV1; import com.mindee.product.multireceiptsdetector.MultiReceiptsDetectorV1; -import com.mindee.product.nutritionfactslabel.NutritionFactsLabelV1; import com.mindee.product.passport.PassportV1; import com.mindee.product.receipt.ReceiptV5; -import com.mindee.product.resume.ResumeV1; -import com.mindee.product.us.bankcheck.BankCheckV1; -import com.mindee.product.us.healthcarecard.HealthcareCardV1; -import com.mindee.product.us.usmail.UsMailV3; import java.io.File; import java.io.IOException; import picocli.CommandLine; @@ -37,7 +26,7 @@ public class CommandLineInterfaceProducts { /** * Default constructor. - * + * * @param processor Processor instance to render the products. */ public CommandLineInterfaceProducts(ProductProcessor processor) { @@ -58,17 +47,6 @@ void bankAccountDetailsV2Method( System.out.println(processor.standardProductOutput(BankAccountDetailsV2.class, file)); } - @CommandLine.Command(name = "us-bank-check", description = "Parse using US Bank Check") - void bankCheckV1Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductOutput(BankCheckV1.class, file)); - } - @CommandLine.Command(name = "barcode-reader", description = "Parse using Barcode Reader") void barcodeReaderV1Method( @CommandLine.Parameters( @@ -80,28 +58,6 @@ void barcodeReaderV1Method( System.out.println(processor.standardProductOutput(BarcodeReaderV1.class, file)); } - @CommandLine.Command(name = "bill-of-lading", description = "Parse using Bill of Lading") - void billOfLadingV1Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductAsyncOutput(BillOfLadingV1.class, file)); - } - - @CommandLine.Command(name = "business-card", description = "Parse using Business Card") - void businessCardV1Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductAsyncOutput(BusinessCardV1.class, file)); - } - @CommandLine.Command(name = "fr-carte-grise", description = "Parse using FR Carte Grise") void carteGriseV1Method( @CommandLine.Parameters( @@ -124,17 +80,6 @@ void cropperV1Method( System.out.println(processor.standardProductOutput(CropperV1.class, file)); } - @CommandLine.Command(name = "delivery-note", description = "Parse using Delivery note") - void deliveryNoteV1Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductAsyncOutput(DeliveryNoteV1.class, file)); - } - @CommandLine.Command(name = "driver-license", description = "Parse using Driver License") void driverLicenseV1Method( @CommandLine.Parameters( @@ -146,17 +91,6 @@ void driverLicenseV1Method( System.out.println(processor.standardProductAsyncOutput(DriverLicenseV1.class, file)); } - @CommandLine.Command(name = "fr-energy-bill", description = "Parse using FR Energy Bill") - void energyBillV1Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductAsyncOutput(EnergyBillV1.class, file)); - } - @CommandLine.Command(name = "financial-document", description = "Parse using Financial Document") void financialDocumentV1Method( @CommandLine.Parameters( @@ -168,28 +102,6 @@ void financialDocumentV1Method( System.out.println(processor.standardProductAsyncOutput(FinancialDocumentV1.class, file)); } - @CommandLine.Command(name = "fr-health-card", description = "Parse using FR Health Card") - void healthCardV1Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductAsyncOutput(HealthCardV1.class, file)); - } - - @CommandLine.Command(name = "us-healthcare-card", description = "Parse using US Healthcare Card") - void healthcareCardV1Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductAsyncOutput(HealthcareCardV1.class, file)); - } - @CommandLine.Command( name = "fr-carte-nationale-d-identite", description = "Parse using FR Carte Nationale d'Identité" @@ -265,20 +177,6 @@ void multiReceiptsDetectorV1Method( System.out.println(processor.standardProductOutput(MultiReceiptsDetectorV1.class, file)); } - @CommandLine.Command( - name = "nutrition-facts-label", - description = "Parse using Nutrition Facts Label" - ) - void nutritionFactsLabelV1Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductAsyncOutput(NutritionFactsLabelV1.class, file)); - } - @CommandLine.Command(name = "passport", description = "Parse using Passport") void passportV1Method( @CommandLine.Parameters( @@ -290,17 +188,6 @@ void passportV1Method( System.out.println(processor.standardProductOutput(PassportV1.class, file)); } - @CommandLine.Command(name = "fr-payslip", description = "Parse using FR Payslip") - void payslipV3Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductAsyncOutput(PayslipV3.class, file)); - } - @CommandLine.Command(name = "receipt", description = "Parse using Receipt") void receiptV5Method( @CommandLine.Parameters( @@ -311,26 +198,4 @@ void receiptV5Method( ) throws IOException, InterruptedException { System.out.println(processor.standardProductAsyncOutput(ReceiptV5.class, file)); } - - @CommandLine.Command(name = "resume", description = "Parse using Resume") - void resumeV1Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductAsyncOutput(ResumeV1.class, file)); - } - - @CommandLine.Command(name = "us-us-mail", description = "Parse using US US Mail") - void usMailV3Method( - @CommandLine.Parameters( - index = "0", - paramLabel = "", - scope = CommandLine.ScopeType.LOCAL - ) File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductAsyncOutput(UsMailV3.class, file)); - } } diff --git a/src/main/java/com/mindee/parsing/custom/ClassificationField.java b/src/main/java/com/mindee/parsing/custom/ClassificationField.java deleted file mode 100644 index f77da7482..000000000 --- a/src/main/java/com/mindee/parsing/custom/ClassificationField.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.mindee.parsing.custom; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * A field holding a classification value. - */ -@Getter -@EqualsAndHashCode -@JsonIgnoreProperties(ignoreUnknown = true) -public class ClassificationField { - - /** - * The confidence about the zone of the value extracted. - * A value from 0 to 1. - */ - @JsonProperty("confidence") - private double confidence; - /** - * The content of the value. - */ - @JsonProperty("value") - private String value; - - @Override - public String toString() { - return value == null ? "" : value; - } -} diff --git a/src/main/java/com/mindee/parsing/custom/CustomV1DocumentPredictionDeserializer.java b/src/main/java/com/mindee/parsing/custom/CustomV1DocumentPredictionDeserializer.java deleted file mode 100644 index 2977466d4..000000000 --- a/src/main/java/com/mindee/parsing/custom/CustomV1DocumentPredictionDeserializer.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.mindee.parsing.custom; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.mindee.product.custom.CustomV1Document; -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * JSON deserializer for custom documents v1.x. - */ -public class CustomV1DocumentPredictionDeserializer extends StdDeserializer { - - private static final ObjectMapper mapper = new ObjectMapper(); - - public CustomV1DocumentPredictionDeserializer(Class vc) { - super(vc); - } - - public CustomV1DocumentPredictionDeserializer() { - this(null); - } - - @Override - public CustomV1Document deserialize( - JsonParser jsonParser, - DeserializationContext deserializationContext - ) throws IOException { - ObjectNode node = jsonParser.getCodec().readTree(jsonParser); - - Map classificationFields = new HashMap<>(); - Map fields = new HashMap<>(); - - for (Iterator> subNode = node.fields(); subNode.hasNext();) { - - Map.Entry pageNode = subNode.next(); - - if (pageNode.getValue().has("value")) { - classificationFields - .put(pageNode.getKey(), mapper.readerFor(new TypeReference() { - }).readValue(pageNode.getValue())); - } else { - fields.put(pageNode.getKey(), mapper.readerFor(new TypeReference() { - }).readValue(pageNode.getValue())); - } - } - - return new CustomV1Document(classificationFields, fields); - } -} diff --git a/src/main/java/com/mindee/parsing/custom/ListField.java b/src/main/java/com/mindee/parsing/custom/ListField.java deleted file mode 100644 index 91cf00739..000000000 --- a/src/main/java/com/mindee/parsing/custom/ListField.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.mindee.parsing.custom; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * A field containing a list of values. - */ -@AllArgsConstructor -@Getter -@EqualsAndHashCode -@JsonIgnoreProperties(ignoreUnknown = true) -public class ListField { - - /** - * The confidence about the zone of the value extracted. - * A value from 0 to 1. - */ - @JsonProperty("confidence") - private double confidence; - /** - * List of defined values available in a field. - */ - @JsonProperty("values") - private List values; - - public ListField() { - this.values = new ArrayList<>(); - } - - /** - * Returns true if there are no values. - * - * @return true if there are no values. - */ - public boolean isEmpty() { - return this.values.isEmpty(); - } - - /** - * Get all the value contents. - * - * @return all the values as a list of strings. - */ - public List getContentsList() { - return values.stream().map(ListFieldValue::getContent).collect(Collectors.toList()); - } - - /** - * Get all the joined value contents. - * - * @param separator the separator to use between values. - * @return all the values as a single string. - */ - public String getContentsString(String separator) { - return String - .format( - "%s", - values.stream().map(ListFieldValue::toString).collect(Collectors.joining(separator)) - ); - } - - @Override - public String toString() { - return getContentsString(" "); - } -} diff --git a/src/main/java/com/mindee/parsing/custom/ListFieldValue.java b/src/main/java/com/mindee/parsing/custom/ListFieldValue.java deleted file mode 100644 index 833094e49..000000000 --- a/src/main/java/com/mindee/parsing/custom/ListFieldValue.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.mindee.parsing.custom; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.geometry.Polygon; -import com.mindee.geometry.PolygonDeserializer; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * A single value in a ListField. - */ -@Getter -@EqualsAndHashCode -@JsonIgnoreProperties(ignoreUnknown = true) -public class ListFieldValue { - - /** - * The confidence about the zone of the value extracted. - * A value from 0 to 1. - */ - @JsonProperty("confidence") - private double confidence; - /** - * Define the coordinates of the zone in the page where the values have been found. - */ - @JsonProperty("polygon") - @JsonDeserialize(using = PolygonDeserializer.class) - private Polygon polygon; - /** - * The content of the value. - */ - @JsonProperty("content") - private String content; - /** - * The document page on which the information was found. - */ - @JsonProperty("page_id") - private Integer pageId; - - public ListFieldValue() { - } - - public ListFieldValue(String content, double confidence, Polygon polygon) { - this.confidence = confidence; - this.polygon = polygon; - this.content = content; - } - - @Override - public String toString() { - return content == null ? "" : content; - } -} diff --git a/src/main/java/com/mindee/parsing/custom/lineitems/Anchor.java b/src/main/java/com/mindee/parsing/custom/lineitems/Anchor.java deleted file mode 100644 index ef37a35d4..000000000 --- a/src/main/java/com/mindee/parsing/custom/lineitems/Anchor.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mindee.parsing.custom.lineitems; - -import lombok.Getter; - -/** - * An anchor column. - */ -@Getter -public final class Anchor { - private final String name; - private final double tolerance; - - /** - * Define an anchor with height tolerance. - */ - public Anchor(String name, double tolerance) { - this.name = name; - this.tolerance = tolerance; - } - - /** - * Define an anchor with no tolerance. - */ - public Anchor(String name) { - this.name = name; - this.tolerance = 0.01d; - } -} diff --git a/src/main/java/com/mindee/parsing/custom/lineitems/Line.java b/src/main/java/com/mindee/parsing/custom/lineitems/Line.java deleted file mode 100644 index 0ba2d41b3..000000000 --- a/src/main/java/com/mindee/parsing/custom/lineitems/Line.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.mindee.parsing.custom.lineitems; - -import com.mindee.geometry.Bbox; -import com.mindee.geometry.BoundingBoxUtils; -import com.mindee.geometry.Polygon; -import com.mindee.geometry.PolygonUtils; -import com.mindee.parsing.custom.ListFieldValue; -import com.mindee.parsing.standard.StringField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; -import lombok.Setter; - -/** - * Represent a single line. - */ -@Getter -public class Line { - private final Integer rowNumber; - private final Map fields; - private final Double heightTolerance; - @Setter - private Bbox bbox; - - public Line(Integer rowNumber, Map fields) { - this.rowNumber = rowNumber; - this.fields = fields; - this.heightTolerance = 0.0; - } - - public Line(Integer rowNumber, Double heightTolerance) { - this.rowNumber = rowNumber; - this.fields = new HashMap<>(); - this.heightTolerance = heightTolerance; - } - - public void addField(String name, ListFieldValue fieldValue) { - if (fields.containsKey(name)) { - StringField existingField = fields.get(name); - - Polygon mergedPolygon = PolygonUtils - .combine( - BoundingBoxUtils.createBoundingBoxFrom(existingField.getPolygon()), - BoundingBoxUtils.createBoundingBoxFrom(fieldValue.getPolygon()) - ); - - String content = existingField.getValue() == null - ? fieldValue.getContent() - : String.join(" ", existingField.getValue(), fieldValue.getContent()); - - fields - .replace( - name, - new StringField( - content, - existingField.getConfidence() * fieldValue.getConfidence(), - mergedPolygon - ) - ); - } else { - fields - .put( - name, - new StringField( - fieldValue.getContent(), - fieldValue.getConfidence(), - fieldValue.getPolygon() - ) - ); - } - } -} diff --git a/src/main/java/com/mindee/parsing/custom/lineitems/LineGenerator.java b/src/main/java/com/mindee/parsing/custom/lineitems/LineGenerator.java deleted file mode 100644 index 1cad9a874..000000000 --- a/src/main/java/com/mindee/parsing/custom/lineitems/LineGenerator.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.mindee.parsing.custom.lineitems; - -import com.mindee.geometry.Bbox; -import com.mindee.geometry.BboxUtils; -import com.mindee.parsing.custom.ListField; -import com.mindee.parsing.custom.ListFieldValue; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.math3.util.Precision; - -/** - * Get lines. - */ -public final class LineGenerator { - - private LineGenerator() { - } - - public static PreparedLines prepareLines(Map fields, List anchors) { - Anchor bestAnchor = null; - Collection lines = null; - int lineCount = 0; - for (Anchor anchor : anchors) { - ListField anchorColumn = fields.get(anchor.getName()); - if (anchorColumn == null) { - throw new IllegalStateException("The field selected for the anchor was not found."); - } - Collection currentLines = createLines(anchorColumn.getValues(), anchor.getTolerance()); - if (currentLines.size() > lineCount) { - bestAnchor = anchor; - lines = currentLines; - lineCount = currentLines.size(); - } - } - if (lines == null) { - throw new IllegalStateException("Could not determine which anchor to use."); - } - return new PreparedLines(bestAnchor, new ArrayList<>(lines)); - } - - private static Collection createLines(List anchorValues, double tolerance) { - HashMap table = new HashMap<>(); - - // handle one value and the case of one line - int lineNumber = 1; - Line currentLine = new Line(lineNumber, tolerance); - ListFieldValue currentValue = anchorValues.get(0); - currentLine.setBbox(currentValue.getPolygon().getAsBbox()); - for (ListFieldValue anchorValue : anchorValues) { - currentValue = anchorValue; - Bbox currentFieldBbox = currentValue.getPolygon().getAsBbox(); - if ( - Precision.equals(currentLine.getBbox().getMinY(), currentFieldBbox.getMinY(), tolerance) - ) { - currentLine - .setBbox(BboxUtils.merge(Arrays.asList(currentLine.getBbox(), currentFieldBbox))); - } else { - // when it is a new line - table.put(lineNumber, currentLine); - lineNumber++; - currentLine = new Line(lineNumber, tolerance); - currentLine.setBbox(currentFieldBbox); - } - } - table.putIfAbsent(lineNumber, currentLine); - return table.values(); - } - -} diff --git a/src/main/java/com/mindee/parsing/custom/lineitems/LineItems.java b/src/main/java/com/mindee/parsing/custom/lineitems/LineItems.java deleted file mode 100644 index 5f9bcd269..000000000 --- a/src/main/java/com/mindee/parsing/custom/lineitems/LineItems.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mindee.parsing.custom.lineitems; - -import java.util.List; -import lombok.Getter; - -/** - * Line items details. - */ -@Getter -public class LineItems { - private List rows; - - /** - * Default constructor. - * - * @param rows - */ - public LineItems(List rows) { - this.rows = rows; - } - -} diff --git a/src/main/java/com/mindee/parsing/custom/lineitems/LineItemsGenerator.java b/src/main/java/com/mindee/parsing/custom/lineitems/LineItemsGenerator.java deleted file mode 100644 index 93fabaf08..000000000 --- a/src/main/java/com/mindee/parsing/custom/lineitems/LineItemsGenerator.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.mindee.parsing.custom.lineitems; - -import com.mindee.geometry.MinMax; -import com.mindee.parsing.custom.ListField; -import com.mindee.parsing.custom.ListFieldValue; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * WARNING: This feature is experimental! - * Results may not always work as intended. - * Don't use unless you know what you're doing ;-) - */ -public final class LineItemsGenerator { - private LineItemsGenerator() { - } - - /** - * Generate line items. - * Use this method if you want to send a list of different possible anchor fields. - * Will use the tolerance settings from the best anchor. - */ - public static LineItems generate( - List fieldNames, - Map fields, - List anchors - ) { - Map fieldsToTransformIntoLines = fields - .entrySet() - .stream() - .filter(field -> fieldNames.contains(field.getKey())) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - return generate(fieldsToTransformIntoLines, anchors); - } - - /** - * Generate line items. - * Use this method if you want to use a single anchor field. - */ - public static LineItems generate( - List fieldNames, - Map fields, - Anchor anchor - ) { - Map fieldsToTransformIntoLines = fields - .entrySet() - .stream() - .filter(field -> fieldNames.contains(field.getKey())) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - List anchors = new ArrayList<>(Collections.singletonList(anchor)); - return generate(fieldsToTransformIntoLines, anchors); - } - - private static LineItems generate( - Map fieldsToTransformIntoLines, - List anchors - ) { - PreparedLines preparedLines = LineGenerator.prepareLines(fieldsToTransformIntoLines, anchors); - List lines = populateLines( - fieldsToTransformIntoLines, - preparedLines.getLines(), - preparedLines.getAnchor().getTolerance() - ); - return new LineItems(lines); - } - - private static List populateLines( - Map fields, - List lines, - double tolerance - ) { - List populatedLines = new ArrayList<>(); - - for (Line currentLine : lines) { - for (Map.Entry field : fields.entrySet()) { - for (ListFieldValue listFieldValue : field.getValue().getValues()) { - MinMax minMaxY = listFieldValue.getPolygon().getMinMaxY(); - - if ( - Math.abs(minMaxY.getMax() - currentLine.getBbox().getMaxY()) <= tolerance - && Math.abs(minMaxY.getMin() - currentLine.getBbox().getMinY()) <= tolerance - ) { - currentLine.addField(field.getKey(), listFieldValue); - } - } - } - populatedLines.add(currentLine); - } - return populatedLines; - } -} diff --git a/src/main/java/com/mindee/parsing/custom/lineitems/PreparedLines.java b/src/main/java/com/mindee/parsing/custom/lineitems/PreparedLines.java deleted file mode 100644 index 3442fc427..000000000 --- a/src/main/java/com/mindee/parsing/custom/lineitems/PreparedLines.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mindee.parsing.custom.lineitems; - -import java.util.List; -import lombok.Getter; - -/** - * An anchor and its initial lines. - */ -@Getter -public final class PreparedLines { - private final Anchor anchor; - private final List lines; - - /** - * An anchor and its initial lines. - */ - public PreparedLines(Anchor anchor, List lines) { - this.anchor = anchor; - this.lines = lines; - } -} diff --git a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1.java b/src/main/java/com/mindee/product/billoflading/BillOfLadingV1.java deleted file mode 100644 index d893ad8b3..000000000 --- a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mindee.product.billoflading; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Bill of Lading API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "bill_of_lading", version = "1") -public class BillOfLadingV1 extends Inference { -} diff --git a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Carrier.java b/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Carrier.java deleted file mode 100644 index 02d16df85..000000000 --- a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Carrier.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.mindee.product.billoflading; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The shipping company responsible for transporting the goods. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class BillOfLadingV1Carrier extends BaseField { - - /** - * The name of the carrier. - */ - @JsonProperty("name") - String name; - /** - * The professional number of the carrier. - */ - @JsonProperty("professional_number") - String professionalNumber; - /** - * The Standard Carrier Alpha Code (SCAC) of the carrier. - */ - @JsonProperty("scac") - String scac; - - public boolean isEmpty() { - return ((name == null || name.isEmpty()) - && (professionalNumber == null || professionalNumber.isEmpty()) - && (scac == null || scac.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Name: %s%n", printable.get("name")) - + String.format(" :Professional Number: %s%n", printable.get("professionalNumber")) - + String.format(" :SCAC: %s%n", printable.get("scac")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Name: %s", printable.get("name")) - + String.format(", Professional Number: %s", printable.get("professionalNumber")) - + String.format(", SCAC: %s", printable.get("scac")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("name", SummaryHelper.formatForDisplay(this.name, null)); - printable - .put("professionalNumber", SummaryHelper.formatForDisplay(this.professionalNumber, null)); - printable.put("scac", SummaryHelper.formatForDisplay(this.scac, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1CarrierItem.java b/src/main/java/com/mindee/product/billoflading/BillOfLadingV1CarrierItem.java deleted file mode 100644 index 5cdd5d5f3..000000000 --- a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1CarrierItem.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.mindee.product.billoflading; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The goods being shipped. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class BillOfLadingV1CarrierItem extends BaseField implements LineItemField { - - /** - * A description of the item. - */ - @JsonProperty("description") - String description; - /** - * The gross weight of the item. - */ - @JsonProperty("gross_weight") - Double grossWeight; - /** - * The measurement of the item. - */ - @JsonProperty("measurement") - Double measurement; - /** - * The unit of measurement for the measurement. - */ - @JsonProperty("measurement_unit") - String measurementUnit; - /** - * The quantity of the item being shipped. - */ - @JsonProperty("quantity") - Double quantity; - /** - * The unit of measurement for weights. - */ - @JsonProperty("weight_unit") - String weightUnit; - - public boolean isEmpty() { - return ((description == null || description.isEmpty()) - && grossWeight == null - && measurement == null - && (measurementUnit == null || measurementUnit.isEmpty()) - && quantity == null - && (weightUnit == null || weightUnit.isEmpty())); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("description", SummaryHelper.formatForDisplay(this.description, 36)); - printable.put("grossWeight", SummaryHelper.formatAmount(this.grossWeight)); - printable.put("measurement", SummaryHelper.formatAmount(this.measurement)); - printable.put("measurementUnit", SummaryHelper.formatForDisplay(this.measurementUnit, null)); - printable.put("quantity", SummaryHelper.formatAmount(this.quantity)); - printable.put("weightUnit", SummaryHelper.formatForDisplay(this.weightUnit, null)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-36s ", printable.get("description")) - + String.format("| %-12s ", printable.get("grossWeight")) - + String.format("| %-11s ", printable.get("measurement")) - + String.format("| %-16s ", printable.get("measurementUnit")) - + String.format("| %-8s ", printable.get("quantity")) - + String.format("| %-11s |", printable.get("weightUnit")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Description: %s", printable.get("description")) - + String.format(", Gross Weight: %s", printable.get("grossWeight")) - + String.format(", Measurement: %s", printable.get("measurement")) - + String.format(", Measurement Unit: %s", printable.get("measurementUnit")) - + String.format(", Quantity: %s", printable.get("quantity")) - + String.format(", Weight Unit: %s", printable.get("weightUnit")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("description", SummaryHelper.formatForDisplay(this.description, null)); - printable.put("grossWeight", SummaryHelper.formatAmount(this.grossWeight)); - printable.put("measurement", SummaryHelper.formatAmount(this.measurement)); - printable.put("measurementUnit", SummaryHelper.formatForDisplay(this.measurementUnit, null)); - printable.put("quantity", SummaryHelper.formatAmount(this.quantity)); - printable.put("weightUnit", SummaryHelper.formatForDisplay(this.weightUnit, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Consignee.java b/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Consignee.java deleted file mode 100644 index 38a566329..000000000 --- a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Consignee.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.mindee.product.billoflading; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The party to whom the goods are being shipped. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class BillOfLadingV1Consignee extends BaseField { - - /** - * The address of the consignee. - */ - @JsonProperty("address") - String address; - /** - * The email of the shipper. - */ - @JsonProperty("email") - String email; - /** - * The name of the consignee. - */ - @JsonProperty("name") - String name; - /** - * The phone number of the consignee. - */ - @JsonProperty("phone") - String phone; - - public boolean isEmpty() { - return ((address == null || address.isEmpty()) - && (email == null || email.isEmpty()) - && (name == null || name.isEmpty()) - && (phone == null || phone.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Address: %s%n", printable.get("address")) - + String.format(" :Email: %s%n", printable.get("email")) - + String.format(" :Name: %s%n", printable.get("name")) - + String.format(" :Phone: %s%n", printable.get("phone")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Address: %s", printable.get("address")) - + String.format(", Email: %s", printable.get("email")) - + String.format(", Name: %s", printable.get("name")) - + String.format(", Phone: %s", printable.get("phone")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("address", SummaryHelper.formatForDisplay(this.address, null)); - printable.put("email", SummaryHelper.formatForDisplay(this.email, null)); - printable.put("name", SummaryHelper.formatForDisplay(this.name, null)); - printable.put("phone", SummaryHelper.formatForDisplay(this.phone, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Document.java b/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Document.java deleted file mode 100644 index 053106c32..000000000 --- a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Document.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.mindee.product.billoflading; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Bill of Lading API version 1.1 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class BillOfLadingV1Document extends Prediction { - - /** - * A unique identifier assigned to a Bill of Lading document. - */ - @JsonProperty("bill_of_lading_number") - protected StringField billOfLadingNumber; - /** - * The shipping company responsible for transporting the goods. - */ - @JsonProperty("carrier") - protected BillOfLadingV1Carrier carrier; - /** - * The goods being shipped. - */ - @JsonProperty("carrier_items") - protected List carrierItems = new ArrayList<>(); - /** - * The party to whom the goods are being shipped. - */ - @JsonProperty("consignee") - protected BillOfLadingV1Consignee consignee; - /** - * The date when the bill of lading is issued. - */ - @JsonProperty("date_of_issue") - protected DateField dateOfIssue; - /** - * The date when the vessel departs from the port of loading. - */ - @JsonProperty("departure_date") - protected DateField departureDate; - /** - * The party to be notified of the arrival of the goods. - */ - @JsonProperty("notify_party") - protected BillOfLadingV1NotifyParty notifyParty; - /** - * The place where the goods are to be delivered. - */ - @JsonProperty("place_of_delivery") - protected StringField placeOfDelivery; - /** - * The port where the goods are unloaded from the vessel. - */ - @JsonProperty("port_of_discharge") - protected StringField portOfDischarge; - /** - * The port where the goods are loaded onto the vessel. - */ - @JsonProperty("port_of_loading") - protected StringField portOfLoading; - /** - * The party responsible for shipping the goods. - */ - @JsonProperty("shipper") - protected BillOfLadingV1Shipper shipper; - - @Override - public boolean isEmpty() { - return (this.billOfLadingNumber == null - && this.shipper == null - && this.consignee == null - && this.notifyParty == null - && this.carrier == null - && (this.carrierItems == null || this.carrierItems.isEmpty()) - && this.portOfLoading == null - && this.portOfDischarge == null - && this.placeOfDelivery == null - && this.dateOfIssue == null - && this.departureDate == null); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Bill of Lading Number: %s%n", this.getBillOfLadingNumber())); - outStr.append(String.format(":Shipper:%n%s", this.getShipper().toFieldList())); - outStr.append(String.format(":Consignee:%n%s", this.getConsignee().toFieldList())); - outStr.append(String.format(":Notify Party:%n%s", this.getNotifyParty().toFieldList())); - outStr.append(String.format(":Carrier:%n%s", this.getCarrier().toFieldList())); - String carrierItemsSummary = ""; - if (!this.getCarrierItems().isEmpty()) { - int[] carrierItemsColSizes = new int[] { 38, 14, 13, 18, 10, 13 }; - carrierItemsSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(carrierItemsColSizes, "-")) - + "| Description " - + "| Gross Weight " - + "| Measurement " - + "| Measurement Unit " - + "| Quantity " - + "| Weight Unit " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(carrierItemsColSizes, "=")); - carrierItemsSummary += SummaryHelper - .arrayToString(this.getCarrierItems(), carrierItemsColSizes); - carrierItemsSummary += String - .format("%n%s", SummaryHelper.lineSeparator(carrierItemsColSizes, "-")); - } - outStr.append(String.format(":Items: %s%n", carrierItemsSummary)); - outStr.append(String.format(":Port of Loading: %s%n", this.getPortOfLoading())); - outStr.append(String.format(":Port of Discharge: %s%n", this.getPortOfDischarge())); - outStr.append(String.format(":Place of Delivery: %s%n", this.getPlaceOfDelivery())); - outStr.append(String.format(":Date of issue: %s%n", this.getDateOfIssue())); - outStr.append(String.format(":Departure Date: %s%n", this.getDepartureDate())); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1NotifyParty.java b/src/main/java/com/mindee/product/billoflading/BillOfLadingV1NotifyParty.java deleted file mode 100644 index 70f5de432..000000000 --- a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1NotifyParty.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.mindee.product.billoflading; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The party to be notified of the arrival of the goods. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class BillOfLadingV1NotifyParty extends BaseField { - - /** - * The address of the notify party. - */ - @JsonProperty("address") - String address; - /** - * The email of the shipper. - */ - @JsonProperty("email") - String email; - /** - * The name of the notify party. - */ - @JsonProperty("name") - String name; - /** - * The phone number of the notify party. - */ - @JsonProperty("phone") - String phone; - - public boolean isEmpty() { - return ((address == null || address.isEmpty()) - && (email == null || email.isEmpty()) - && (name == null || name.isEmpty()) - && (phone == null || phone.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Address: %s%n", printable.get("address")) - + String.format(" :Email: %s%n", printable.get("email")) - + String.format(" :Name: %s%n", printable.get("name")) - + String.format(" :Phone: %s%n", printable.get("phone")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Address: %s", printable.get("address")) - + String.format(", Email: %s", printable.get("email")) - + String.format(", Name: %s", printable.get("name")) - + String.format(", Phone: %s", printable.get("phone")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("address", SummaryHelper.formatForDisplay(this.address, null)); - printable.put("email", SummaryHelper.formatForDisplay(this.email, null)); - printable.put("name", SummaryHelper.formatForDisplay(this.name, null)); - printable.put("phone", SummaryHelper.formatForDisplay(this.phone, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Shipper.java b/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Shipper.java deleted file mode 100644 index d478dde0b..000000000 --- a/src/main/java/com/mindee/product/billoflading/BillOfLadingV1Shipper.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.mindee.product.billoflading; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The party responsible for shipping the goods. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class BillOfLadingV1Shipper extends BaseField { - - /** - * The address of the shipper. - */ - @JsonProperty("address") - String address; - /** - * The email of the shipper. - */ - @JsonProperty("email") - String email; - /** - * The name of the shipper. - */ - @JsonProperty("name") - String name; - /** - * The phone number of the shipper. - */ - @JsonProperty("phone") - String phone; - - public boolean isEmpty() { - return ((address == null || address.isEmpty()) - && (email == null || email.isEmpty()) - && (name == null || name.isEmpty()) - && (phone == null || phone.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Address: %s%n", printable.get("address")) - + String.format(" :Email: %s%n", printable.get("email")) - + String.format(" :Name: %s%n", printable.get("name")) - + String.format(" :Phone: %s%n", printable.get("phone")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Address: %s", printable.get("address")) - + String.format(", Email: %s", printable.get("email")) - + String.format(", Name: %s", printable.get("name")) - + String.format(", Phone: %s", printable.get("phone")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("address", SummaryHelper.formatForDisplay(this.address, null)); - printable.put("email", SummaryHelper.formatForDisplay(this.email, null)); - printable.put("name", SummaryHelper.formatForDisplay(this.name, null)); - printable.put("phone", SummaryHelper.formatForDisplay(this.phone, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/businesscard/BusinessCardV1.java b/src/main/java/com/mindee/product/businesscard/BusinessCardV1.java deleted file mode 100644 index 97f6066e3..000000000 --- a/src/main/java/com/mindee/product/businesscard/BusinessCardV1.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mindee.product.businesscard; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Business Card API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "business_card", version = "1") -public class BusinessCardV1 extends Inference { -} diff --git a/src/main/java/com/mindee/product/businesscard/BusinessCardV1Document.java b/src/main/java/com/mindee/product/businesscard/BusinessCardV1Document.java deleted file mode 100644 index 000e74270..000000000 --- a/src/main/java/com/mindee/product/businesscard/BusinessCardV1Document.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.mindee.product.businesscard; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.StringField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Business Card API version 1.0 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class BusinessCardV1Document extends Prediction { - - /** - * The address of the person. - */ - @JsonProperty("address") - protected StringField address; - /** - * The company the person works for. - */ - @JsonProperty("company") - protected StringField company; - /** - * The email address of the person. - */ - @JsonProperty("email") - protected StringField email; - /** - * The Fax number of the person. - */ - @JsonProperty("fax_number") - protected StringField faxNumber; - /** - * The given name of the person. - */ - @JsonProperty("firstname") - protected StringField firstname; - /** - * The job title of the person. - */ - @JsonProperty("job_title") - protected StringField jobTitle; - /** - * The lastname of the person. - */ - @JsonProperty("lastname") - protected StringField lastname; - /** - * The mobile number of the person. - */ - @JsonProperty("mobile_number") - protected StringField mobileNumber; - /** - * The phone number of the person. - */ - @JsonProperty("phone_number") - protected StringField phoneNumber; - /** - * The social media profiles of the person or company. - */ - @JsonProperty("social_media") - protected List socialMedia = new ArrayList<>(); - /** - * The website of the person or company. - */ - @JsonProperty("website") - protected StringField website; - - @Override - public boolean isEmpty() { - return (this.firstname == null - && this.lastname == null - && this.jobTitle == null - && this.company == null - && this.email == null - && this.phoneNumber == null - && this.mobileNumber == null - && this.faxNumber == null - && this.address == null - && this.website == null - && (this.socialMedia == null || this.socialMedia.isEmpty())); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Firstname: %s%n", this.getFirstname())); - outStr.append(String.format(":Lastname: %s%n", this.getLastname())); - outStr.append(String.format(":Job Title: %s%n", this.getJobTitle())); - outStr.append(String.format(":Company: %s%n", this.getCompany())); - outStr.append(String.format(":Email: %s%n", this.getEmail())); - outStr.append(String.format(":Phone Number: %s%n", this.getPhoneNumber())); - outStr.append(String.format(":Mobile Number: %s%n", this.getMobileNumber())); - outStr.append(String.format(":Fax Number: %s%n", this.getFaxNumber())); - outStr.append(String.format(":Address: %s%n", this.getAddress())); - outStr.append(String.format(":Website: %s%n", this.getWebsite())); - String socialMedia = SummaryHelper.arrayToString(this.getSocialMedia(), "%n "); - outStr.append(String.format(":Social Media: %s%n", socialMedia)); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/custom/CustomV1.java b/src/main/java/com/mindee/product/custom/CustomV1.java deleted file mode 100644 index c54484815..000000000 --- a/src/main/java/com/mindee/product/custom/CustomV1.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.mindee.product.custom; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Define a simple model to encapsulate data from a custom API builder model. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class CustomV1 extends Inference { - -} diff --git a/src/main/java/com/mindee/product/custom/CustomV1Document.java b/src/main/java/com/mindee/product/custom/CustomV1Document.java deleted file mode 100644 index 27faa41b6..000000000 --- a/src/main/java/com/mindee/product/custom/CustomV1Document.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.mindee.product.custom; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.custom.ClassificationField; -import com.mindee.parsing.custom.CustomV1DocumentPredictionDeserializer; -import com.mindee.parsing.custom.ListField; -import java.util.Map; -import java.util.TreeMap; -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Document data for custom documents, API version 1.x. - */ -@AllArgsConstructor -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonDeserialize(using = CustomV1DocumentPredictionDeserializer.class) -public class CustomV1Document extends Prediction { - - /** - * Classification fields. - */ - private Map classificationFields; - - /** - * Fields that are not classifications. - */ - private Map fields; - - /** - * Returns true if there are no predictions values. - */ - public boolean isEmpty() { - return fields.isEmpty() && classificationFields.isEmpty(); - } - - @Override - public String toString() { - - TreeMap sorted = new TreeMap<>(fields); - - StringBuilder summary = new StringBuilder(); - - for (Map.Entry entry : classificationFields.entrySet()) { - summary.append(String.format(":%s: %s%n", entry.getKey(), entry.getValue())); - } - for (Map.Entry entry : sorted.entrySet()) { - summary.append(String.format(":%s: %s%n", entry.getKey(), entry.getValue())); - } - - return SummaryHelper.cleanSummary(summary.toString()); - } -} diff --git a/src/main/java/com/mindee/product/custom/CustomV1Page.java b/src/main/java/com/mindee/product/custom/CustomV1Page.java deleted file mode 100644 index 4f8d3e8dc..000000000 --- a/src/main/java/com/mindee/product/custom/CustomV1Page.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.mindee.product.custom; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.custom.ListField; -import java.util.HashMap; -import java.util.TreeMap; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Page data for custom documents, API version 1.x. - */ -@Getter -@EqualsAndHashCode -@JsonIgnoreProperties(ignoreUnknown = true) -public class CustomV1Page extends HashMap { - - @Override - public String toString() { - - TreeMap sorted = new TreeMap<>(this); - - StringBuilder summary = new StringBuilder(); - - for (Entry entry : sorted.entrySet()) { - summary.append(String.format(":%s: %s%n", entry.getKey(), entry.getValue())); - } - - return SummaryHelper.cleanSummary(summary.toString()); - } -} diff --git a/src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1.java b/src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1.java deleted file mode 100644 index 3889d1b87..000000000 --- a/src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mindee.product.deliverynote; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Delivery note API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "delivery_notes", version = "1") -public class DeliveryNoteV1 extends Inference { -} diff --git a/src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1Document.java b/src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1Document.java deleted file mode 100644 index 3e8d06151..000000000 --- a/src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1Document.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.mindee.product.deliverynote; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.AmountField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Delivery note API version 1.2 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class DeliveryNoteV1Document extends Prediction { - - /** - * The address of the customer receiving the goods. - */ - @JsonProperty("customer_address") - protected StringField customerAddress; - /** - * The name of the customer receiving the goods. - */ - @JsonProperty("customer_name") - protected StringField customerName; - /** - * The date on which the delivery is scheduled to arrive. - */ - @JsonProperty("delivery_date") - protected DateField deliveryDate; - /** - * A unique identifier for the delivery note. - */ - @JsonProperty("delivery_number") - protected StringField deliveryNumber; - /** - * The address of the supplier providing the goods. - */ - @JsonProperty("supplier_address") - protected StringField supplierAddress; - /** - * The name of the supplier providing the goods. - */ - @JsonProperty("supplier_name") - protected StringField supplierName; - /** - * The total monetary value of the goods being delivered. - */ - @JsonProperty("total_amount") - protected AmountField totalAmount; - - @Override - public boolean isEmpty() { - return (this.deliveryDate == null - && this.deliveryNumber == null - && this.supplierName == null - && this.supplierAddress == null - && this.customerName == null - && this.customerAddress == null - && this.totalAmount == null); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Delivery Date: %s%n", this.getDeliveryDate())); - outStr.append(String.format(":Delivery Number: %s%n", this.getDeliveryNumber())); - outStr.append(String.format(":Supplier Name: %s%n", this.getSupplierName())); - outStr.append(String.format(":Supplier Address: %s%n", this.getSupplierAddress())); - outStr.append(String.format(":Customer Name: %s%n", this.getCustomerName())); - outStr.append(String.format(":Customer Address: %s%n", this.getCustomerAddress())); - outStr.append(String.format(":Total Amount: %s%n", this.getTotalAmount())); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1.java b/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1.java deleted file mode 100644 index 44c285c1a..000000000 --- a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mindee.product.fr.bankaccountdetails; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Bank Account Details API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "bank_account_details", version = "1") -public class BankAccountDetailsV1 - extends Inference { -} diff --git a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1Document.java b/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1Document.java deleted file mode 100644 index 9be2de22a..000000000 --- a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1Document.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.mindee.product.fr.bankaccountdetails; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.StringField; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Bank Account Details API version 1.0 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class BankAccountDetailsV1Document extends Prediction { - - /** - * The name of the account holder as seen on the document. - */ - @JsonProperty("account_holder_name") - protected StringField accountHolderName; - /** - * The International Bank Account Number (IBAN). - */ - @JsonProperty("iban") - protected StringField iban; - /** - * The bank's SWIFT Business Identifier Code (BIC). - */ - @JsonProperty("swift") - protected StringField swift; - - @Override - public boolean isEmpty() { - return (this.iban == null && this.accountHolderName == null && this.swift == null); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":IBAN: %s%n", this.getIban())); - outStr.append(String.format(":Account Holder's Name: %s%n", this.getAccountHolderName())); - outStr.append(String.format(":SWIFT Code: %s%n", this.getSwift())); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1.java b/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1.java deleted file mode 100644 index 3d267e740..000000000 --- a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mindee.product.fr.energybill; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Energy Bill API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "energy_bill_fra", version = "1") -public class EnergyBillV1 extends Inference { -} diff --git a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1Document.java b/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1Document.java deleted file mode 100644 index e6d023215..000000000 --- a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1Document.java +++ /dev/null @@ -1,185 +0,0 @@ -package com.mindee.product.fr.energybill; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.AmountField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Energy Bill API version 1.2 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class EnergyBillV1Document extends Prediction { - - /** - * The unique identifier associated with a specific contract. - */ - @JsonProperty("contract_id") - protected StringField contractId; - /** - * The unique identifier assigned to each electricity or gas consumption point. It specifies the - * exact location where the energy is delivered. - */ - @JsonProperty("delivery_point") - protected StringField deliveryPoint; - /** - * The date by which the payment for the energy invoice is due. - */ - @JsonProperty("due_date") - protected DateField dueDate; - /** - * The entity that consumes the energy. - */ - @JsonProperty("energy_consumer") - protected EnergyBillV1EnergyConsumer energyConsumer; - /** - * The company that supplies the energy. - */ - @JsonProperty("energy_supplier") - protected EnergyBillV1EnergySupplier energySupplier; - /** - * Details of energy consumption. - */ - @JsonProperty("energy_usage") - protected List energyUsage = new ArrayList<>(); - /** - * The date when the energy invoice was issued. - */ - @JsonProperty("invoice_date") - protected DateField invoiceDate; - /** - * The unique identifier of the energy invoice. - */ - @JsonProperty("invoice_number") - protected StringField invoiceNumber; - /** - * Information about the energy meter. - */ - @JsonProperty("meter_details") - protected EnergyBillV1MeterDetail meterDetails; - /** - * The subscription details fee for the energy service. - */ - @JsonProperty("subscription") - protected List subscription = new ArrayList<>(); - /** - * Details of Taxes and Contributions. - */ - @JsonProperty("taxes_and_contributions") - protected List taxesAndContributions = new ArrayList<>(); - /** - * The total amount to be paid for the energy invoice. - */ - @JsonProperty("total_amount") - protected AmountField totalAmount; - /** - * The total amount to be paid for the energy invoice before taxes. - */ - @JsonProperty("total_before_taxes") - protected AmountField totalBeforeTaxes; - /** - * Total of taxes applied to the invoice. - */ - @JsonProperty("total_taxes") - protected AmountField totalTaxes; - - @Override - public boolean isEmpty() { - return (this.invoiceNumber == null - && this.contractId == null - && this.deliveryPoint == null - && this.invoiceDate == null - && this.dueDate == null - && this.totalBeforeTaxes == null - && this.totalTaxes == null - && this.totalAmount == null - && this.energySupplier == null - && this.energyConsumer == null - && (this.subscription == null || this.subscription.isEmpty()) - && (this.energyUsage == null || this.energyUsage.isEmpty()) - && (this.taxesAndContributions == null || this.taxesAndContributions.isEmpty()) - && this.meterDetails == null); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Invoice Number: %s%n", this.getInvoiceNumber())); - outStr.append(String.format(":Contract ID: %s%n", this.getContractId())); - outStr.append(String.format(":Delivery Point: %s%n", this.getDeliveryPoint())); - outStr.append(String.format(":Invoice Date: %s%n", this.getInvoiceDate())); - outStr.append(String.format(":Due Date: %s%n", this.getDueDate())); - outStr.append(String.format(":Total Before Taxes: %s%n", this.getTotalBeforeTaxes())); - outStr.append(String.format(":Total Taxes: %s%n", this.getTotalTaxes())); - outStr.append(String.format(":Total Amount: %s%n", this.getTotalAmount())); - outStr.append(String.format(":Energy Supplier:%n%s", this.getEnergySupplier().toFieldList())); - outStr.append(String.format(":Energy Consumer:%n%s", this.getEnergyConsumer().toFieldList())); - String subscriptionSummary = ""; - if (!this.getSubscription().isEmpty()) { - int[] subscriptionColSizes = new int[] { 38, 12, 12, 10, 11, 12 }; - subscriptionSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(subscriptionColSizes, "-")) - + "| Description " - + "| End Date " - + "| Start Date " - + "| Tax Rate " - + "| Total " - + "| Unit Price " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(subscriptionColSizes, "=")); - subscriptionSummary += SummaryHelper - .arrayToString(this.getSubscription(), subscriptionColSizes); - subscriptionSummary += String - .format("%n%s", SummaryHelper.lineSeparator(subscriptionColSizes, "-")); - } - outStr.append(String.format(":Subscription: %s%n", subscriptionSummary)); - String energyUsageSummary = ""; - if (!this.getEnergyUsage().isEmpty()) { - int[] energyUsageColSizes = new int[] { 13, 38, 12, 12, 10, 11, 17, 12 }; - energyUsageSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(energyUsageColSizes, "-")) - + "| Consumption " - + "| Description " - + "| End Date " - + "| Start Date " - + "| Tax Rate " - + "| Total " - + "| Unit of Measure " - + "| Unit Price " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(energyUsageColSizes, "=")); - energyUsageSummary += SummaryHelper.arrayToString(this.getEnergyUsage(), energyUsageColSizes); - energyUsageSummary += String - .format("%n%s", SummaryHelper.lineSeparator(energyUsageColSizes, "-")); - } - outStr.append(String.format(":Energy Usage: %s%n", energyUsageSummary)); - String taxesAndContributionsSummary = ""; - if (!this.getTaxesAndContributions().isEmpty()) { - int[] taxesAndContributionsColSizes = new int[] { 38, 12, 12, 10, 11, 12 }; - taxesAndContributionsSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(taxesAndContributionsColSizes, "-")) - + "| Description " - + "| End Date " - + "| Start Date " - + "| Tax Rate " - + "| Total " - + "| Unit Price " - + String - .format("|%n%s%n ", SummaryHelper.lineSeparator(taxesAndContributionsColSizes, "=")); - taxesAndContributionsSummary += SummaryHelper - .arrayToString(this.getTaxesAndContributions(), taxesAndContributionsColSizes); - taxesAndContributionsSummary += String - .format("%n%s", SummaryHelper.lineSeparator(taxesAndContributionsColSizes, "-")); - } - outStr.append(String.format(":Taxes and Contributions: %s%n", taxesAndContributionsSummary)); - outStr.append(String.format(":Meter Details:%n%s", this.getMeterDetails().toFieldList())); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergyConsumer.java b/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergyConsumer.java deleted file mode 100644 index f2df3287f..000000000 --- a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergyConsumer.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.mindee.product.fr.energybill; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The entity that consumes the energy. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class EnergyBillV1EnergyConsumer extends BaseField { - - /** - * The address of the energy consumer. - */ - @JsonProperty("address") - String address; - /** - * The name of the energy consumer. - */ - @JsonProperty("name") - String name; - - public boolean isEmpty() { - return ((address == null || address.isEmpty()) && (name == null || name.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Address: %s%n", printable.get("address")) - + String.format(" :Name: %s%n", printable.get("name")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Address: %s", printable.get("address")) - + String.format(", Name: %s", printable.get("name")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("address", SummaryHelper.formatForDisplay(this.address, null)); - printable.put("name", SummaryHelper.formatForDisplay(this.name, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergySupplier.java b/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergySupplier.java deleted file mode 100644 index 23b5044b8..000000000 --- a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergySupplier.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.mindee.product.fr.energybill; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The company that supplies the energy. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class EnergyBillV1EnergySupplier extends BaseField { - - /** - * The address of the energy supplier. - */ - @JsonProperty("address") - String address; - /** - * The name of the energy supplier. - */ - @JsonProperty("name") - String name; - - public boolean isEmpty() { - return ((address == null || address.isEmpty()) && (name == null || name.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Address: %s%n", printable.get("address")) - + String.format(" :Name: %s%n", printable.get("name")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Address: %s", printable.get("address")) - + String.format(", Name: %s", printable.get("name")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("address", SummaryHelper.formatForDisplay(this.address, null)); - printable.put("name", SummaryHelper.formatForDisplay(this.name, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergyUsage.java b/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergyUsage.java deleted file mode 100644 index 1cbbc7169..000000000 --- a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1EnergyUsage.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.mindee.product.fr.energybill; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Details of energy consumption. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class EnergyBillV1EnergyUsage extends BaseField implements LineItemField { - - /** - * The price per unit of energy consumed. - */ - @JsonProperty("consumption") - Double consumption; - /** - * Description or details of the energy usage. - */ - @JsonProperty("description") - String description; - /** - * The end date of the energy usage. - */ - @JsonProperty("end_date") - String endDate; - /** - * The start date of the energy usage. - */ - @JsonProperty("start_date") - String startDate; - /** - * The rate of tax applied to the total cost. - */ - @JsonProperty("tax_rate") - Double taxRate; - /** - * The total cost of energy consumed. - */ - @JsonProperty("total") - Double total; - /** - * The unit of measurement for energy consumption. - */ - @JsonProperty("unit") - String unit; - /** - * The price per unit of energy consumed. - */ - @JsonProperty("unit_price") - Double unitPrice; - - public boolean isEmpty() { - return (consumption == null - && (description == null || description.isEmpty()) - && (endDate == null || endDate.isEmpty()) - && (startDate == null || startDate.isEmpty()) - && taxRate == null - && total == null - && (unit == null || unit.isEmpty()) - && unitPrice == null); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("consumption", SummaryHelper.formatAmount(this.consumption)); - printable.put("description", SummaryHelper.formatForDisplay(this.description, 36)); - printable.put("endDate", SummaryHelper.formatForDisplay(this.endDate, 10)); - printable.put("startDate", SummaryHelper.formatForDisplay(this.startDate, null)); - printable.put("taxRate", SummaryHelper.formatAmount(this.taxRate)); - printable.put("total", SummaryHelper.formatAmount(this.total)); - printable.put("unit", SummaryHelper.formatForDisplay(this.unit, null)); - printable.put("unitPrice", SummaryHelper.formatAmount(this.unitPrice)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-11s ", printable.get("consumption")) - + String.format("| %-36s ", printable.get("description")) - + String.format("| %-10s ", printable.get("endDate")) - + String.format("| %-10s ", printable.get("startDate")) - + String.format("| %-8s ", printable.get("taxRate")) - + String.format("| %-9s ", printable.get("total")) - + String.format("| %-15s ", printable.get("unit")) - + String.format("| %-10s |", printable.get("unitPrice")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Consumption: %s", printable.get("consumption")) - + String.format(", Description: %s", printable.get("description")) - + String.format(", End Date: %s", printable.get("endDate")) - + String.format(", Start Date: %s", printable.get("startDate")) - + String.format(", Tax Rate: %s", printable.get("taxRate")) - + String.format(", Total: %s", printable.get("total")) - + String.format(", Unit of Measure: %s", printable.get("unit")) - + String.format(", Unit Price: %s", printable.get("unitPrice")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("consumption", SummaryHelper.formatAmount(this.consumption)); - printable.put("description", SummaryHelper.formatForDisplay(this.description, null)); - printable.put("endDate", SummaryHelper.formatForDisplay(this.endDate, null)); - printable.put("startDate", SummaryHelper.formatForDisplay(this.startDate, null)); - printable.put("taxRate", SummaryHelper.formatAmount(this.taxRate)); - printable.put("total", SummaryHelper.formatAmount(this.total)); - printable.put("unit", SummaryHelper.formatForDisplay(this.unit, null)); - printable.put("unitPrice", SummaryHelper.formatAmount(this.unitPrice)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1MeterDetail.java b/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1MeterDetail.java deleted file mode 100644 index 8cbb0ad3e..000000000 --- a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1MeterDetail.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.mindee.product.fr.energybill; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Information about the energy meter. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class EnergyBillV1MeterDetail extends BaseField { - - /** - * The unique identifier of the energy meter. - */ - @JsonProperty("meter_number") - String meterNumber; - /** - * The type of energy meter. - */ - @JsonProperty("meter_type") - String meterType; - /** - * The unit of power for energy consumption. - */ - @JsonProperty("unit") - String unit; - - public boolean isEmpty() { - return ((meterNumber == null || meterNumber.isEmpty()) - && (meterType == null || meterType.isEmpty()) - && (unit == null || unit.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Meter Number: %s%n", printable.get("meterNumber")) - + String.format(" :Meter Type: %s%n", printable.get("meterType")) - + String.format(" :Unit of Power: %s%n", printable.get("unit")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Meter Number: %s", printable.get("meterNumber")) - + String.format(", Meter Type: %s", printable.get("meterType")) - + String.format(", Unit of Power: %s", printable.get("unit")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("meterNumber", SummaryHelper.formatForDisplay(this.meterNumber, null)); - printable.put("meterType", SummaryHelper.formatForDisplay(this.meterType, null)); - printable.put("unit", SummaryHelper.formatForDisplay(this.unit, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1Subscription.java b/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1Subscription.java deleted file mode 100644 index 8759b7974..000000000 --- a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1Subscription.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.mindee.product.fr.energybill; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The subscription details fee for the energy service. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class EnergyBillV1Subscription extends BaseField implements LineItemField { - - /** - * Description or details of the subscription. - */ - @JsonProperty("description") - String description; - /** - * The end date of the subscription. - */ - @JsonProperty("end_date") - String endDate; - /** - * The start date of the subscription. - */ - @JsonProperty("start_date") - String startDate; - /** - * The rate of tax applied to the total cost. - */ - @JsonProperty("tax_rate") - Double taxRate; - /** - * The total cost of subscription. - */ - @JsonProperty("total") - Double total; - /** - * The price per unit of subscription. - */ - @JsonProperty("unit_price") - Double unitPrice; - - public boolean isEmpty() { - return ((description == null || description.isEmpty()) - && (endDate == null || endDate.isEmpty()) - && (startDate == null || startDate.isEmpty()) - && taxRate == null - && total == null - && unitPrice == null); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("description", SummaryHelper.formatForDisplay(this.description, 36)); - printable.put("endDate", SummaryHelper.formatForDisplay(this.endDate, 10)); - printable.put("startDate", SummaryHelper.formatForDisplay(this.startDate, null)); - printable.put("taxRate", SummaryHelper.formatAmount(this.taxRate)); - printable.put("total", SummaryHelper.formatAmount(this.total)); - printable.put("unitPrice", SummaryHelper.formatAmount(this.unitPrice)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-36s ", printable.get("description")) - + String.format("| %-10s ", printable.get("endDate")) - + String.format("| %-10s ", printable.get("startDate")) - + String.format("| %-8s ", printable.get("taxRate")) - + String.format("| %-9s ", printable.get("total")) - + String.format("| %-10s |", printable.get("unitPrice")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Description: %s", printable.get("description")) - + String.format(", End Date: %s", printable.get("endDate")) - + String.format(", Start Date: %s", printable.get("startDate")) - + String.format(", Tax Rate: %s", printable.get("taxRate")) - + String.format(", Total: %s", printable.get("total")) - + String.format(", Unit Price: %s", printable.get("unitPrice")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("description", SummaryHelper.formatForDisplay(this.description, null)); - printable.put("endDate", SummaryHelper.formatForDisplay(this.endDate, null)); - printable.put("startDate", SummaryHelper.formatForDisplay(this.startDate, null)); - printable.put("taxRate", SummaryHelper.formatAmount(this.taxRate)); - printable.put("total", SummaryHelper.formatAmount(this.total)); - printable.put("unitPrice", SummaryHelper.formatAmount(this.unitPrice)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1TaxesAndContribution.java b/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1TaxesAndContribution.java deleted file mode 100644 index 37f96bc04..000000000 --- a/src/main/java/com/mindee/product/fr/energybill/EnergyBillV1TaxesAndContribution.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.mindee.product.fr.energybill; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Details of Taxes and Contributions. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class EnergyBillV1TaxesAndContribution extends BaseField implements LineItemField { - - /** - * Description or details of the Taxes and Contributions. - */ - @JsonProperty("description") - String description; - /** - * The end date of the Taxes and Contributions. - */ - @JsonProperty("end_date") - String endDate; - /** - * The start date of the Taxes and Contributions. - */ - @JsonProperty("start_date") - String startDate; - /** - * The rate of tax applied to the total cost. - */ - @JsonProperty("tax_rate") - Double taxRate; - /** - * The total cost of Taxes and Contributions. - */ - @JsonProperty("total") - Double total; - /** - * The price per unit of Taxes and Contributions. - */ - @JsonProperty("unit_price") - Double unitPrice; - - public boolean isEmpty() { - return ((description == null || description.isEmpty()) - && (endDate == null || endDate.isEmpty()) - && (startDate == null || startDate.isEmpty()) - && taxRate == null - && total == null - && unitPrice == null); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("description", SummaryHelper.formatForDisplay(this.description, 36)); - printable.put("endDate", SummaryHelper.formatForDisplay(this.endDate, 10)); - printable.put("startDate", SummaryHelper.formatForDisplay(this.startDate, null)); - printable.put("taxRate", SummaryHelper.formatAmount(this.taxRate)); - printable.put("total", SummaryHelper.formatAmount(this.total)); - printable.put("unitPrice", SummaryHelper.formatAmount(this.unitPrice)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-36s ", printable.get("description")) - + String.format("| %-10s ", printable.get("endDate")) - + String.format("| %-10s ", printable.get("startDate")) - + String.format("| %-8s ", printable.get("taxRate")) - + String.format("| %-9s ", printable.get("total")) - + String.format("| %-10s |", printable.get("unitPrice")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Description: %s", printable.get("description")) - + String.format(", End Date: %s", printable.get("endDate")) - + String.format(", Start Date: %s", printable.get("startDate")) - + String.format(", Tax Rate: %s", printable.get("taxRate")) - + String.format(", Total: %s", printable.get("total")) - + String.format(", Unit Price: %s", printable.get("unitPrice")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("description", SummaryHelper.formatForDisplay(this.description, null)); - printable.put("endDate", SummaryHelper.formatForDisplay(this.endDate, null)); - printable.put("startDate", SummaryHelper.formatForDisplay(this.startDate, null)); - printable.put("taxRate", SummaryHelper.formatAmount(this.taxRate)); - printable.put("total", SummaryHelper.formatAmount(this.total)); - printable.put("unitPrice", SummaryHelper.formatAmount(this.unitPrice)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/healthcard/HealthCardV1.java b/src/main/java/com/mindee/product/fr/healthcard/HealthCardV1.java deleted file mode 100644 index dee9fd4b5..000000000 --- a/src/main/java/com/mindee/product/fr/healthcard/HealthCardV1.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mindee.product.fr.healthcard; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Health Card API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "french_healthcard", version = "1") -public class HealthCardV1 extends Inference { -} diff --git a/src/main/java/com/mindee/product/fr/healthcard/HealthCardV1Document.java b/src/main/java/com/mindee/product/fr/healthcard/HealthCardV1Document.java deleted file mode 100644 index cf58fe59d..000000000 --- a/src/main/java/com/mindee/product/fr/healthcard/HealthCardV1Document.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.mindee.product.fr.healthcard; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Health Card API version 1.0 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class HealthCardV1Document extends Prediction { - - /** - * The given names of the card holder. - */ - @JsonProperty("given_names") - protected List givenNames = new ArrayList<>(); - /** - * The date when the carte vitale document was issued. - */ - @JsonProperty("issuance_date") - protected DateField issuanceDate; - /** - * The social security number of the card holder. - */ - @JsonProperty("social_security") - protected StringField socialSecurity; - /** - * The surname of the card holder. - */ - @JsonProperty("surname") - protected StringField surname; - - @Override - public boolean isEmpty() { - return ((this.givenNames == null || this.givenNames.isEmpty()) - && this.surname == null - && this.socialSecurity == null - && this.issuanceDate == null); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - String givenNames = SummaryHelper.arrayToString(this.getGivenNames(), "%n "); - outStr.append(String.format(":Given Name(s): %s%n", givenNames)); - outStr.append(String.format(":Surname: %s%n", this.getSurname())); - outStr.append(String.format(":Social Security Number: %s%n", this.getSocialSecurity())); - outStr.append(String.format(":Issuance Date: %s%n", this.getIssuanceDate())); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/fr/payslip/PayslipV3.java b/src/main/java/com/mindee/product/fr/payslip/PayslipV3.java deleted file mode 100644 index f0b989d5d..000000000 --- a/src/main/java/com/mindee/product/fr/payslip/PayslipV3.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mindee.product.fr.payslip; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Payslip API version 3 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "payslip_fra", version = "3") -public class PayslipV3 extends Inference { -} diff --git a/src/main/java/com/mindee/product/fr/payslip/PayslipV3BankAccountDetail.java b/src/main/java/com/mindee/product/fr/payslip/PayslipV3BankAccountDetail.java deleted file mode 100644 index 81e1de6c4..000000000 --- a/src/main/java/com/mindee/product/fr/payslip/PayslipV3BankAccountDetail.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.mindee.product.fr.payslip; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Information about the employee's bank account. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class PayslipV3BankAccountDetail extends BaseField { - - /** - * The name of the bank. - */ - @JsonProperty("bank_name") - String bankName; - /** - * The IBAN of the bank account. - */ - @JsonProperty("iban") - String iban; - /** - * The SWIFT code of the bank. - */ - @JsonProperty("swift") - String swift; - - public boolean isEmpty() { - return ((bankName == null || bankName.isEmpty()) - && (iban == null || iban.isEmpty()) - && (swift == null || swift.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Bank Name: %s%n", printable.get("bankName")) - + String.format(" :IBAN: %s%n", printable.get("iban")) - + String.format(" :SWIFT: %s%n", printable.get("swift")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Bank Name: %s", printable.get("bankName")) - + String.format(", IBAN: %s", printable.get("iban")) - + String.format(", SWIFT: %s", printable.get("swift")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("bankName", SummaryHelper.formatForDisplay(this.bankName, null)); - printable.put("iban", SummaryHelper.formatForDisplay(this.iban, null)); - printable.put("swift", SummaryHelper.formatForDisplay(this.swift, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/payslip/PayslipV3Document.java b/src/main/java/com/mindee/product/fr/payslip/PayslipV3Document.java deleted file mode 100644 index c8317d599..000000000 --- a/src/main/java/com/mindee/product/fr/payslip/PayslipV3Document.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.mindee.product.fr.payslip; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Payslip API version 3.0 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class PayslipV3Document extends Prediction { - - /** - * Information about the employee's bank account. - */ - @JsonProperty("bank_account_details") - protected PayslipV3BankAccountDetail bankAccountDetails; - /** - * Information about the employee. - */ - @JsonProperty("employee") - protected PayslipV3Employee employee; - /** - * Information about the employer. - */ - @JsonProperty("employer") - protected PayslipV3Employer employer; - /** - * Information about the employment. - */ - @JsonProperty("employment") - protected PayslipV3Employment employment; - /** - * Information about paid time off. - */ - @JsonProperty("paid_time_off") - protected List paidTimeOff = new ArrayList<>(); - /** - * Detailed information about the pay. - */ - @JsonProperty("pay_detail") - protected PayslipV3PayDetail payDetail; - /** - * Information about the pay period. - */ - @JsonProperty("pay_period") - protected PayslipV3PayPeriod payPeriod; - /** - * Detailed information about the earnings. - */ - @JsonProperty("salary_details") - protected List salaryDetails = new ArrayList<>(); - - @Override - public boolean isEmpty() { - return (this.payPeriod == null - && this.employee == null - && this.employer == null - && this.bankAccountDetails == null - && this.employment == null - && (this.salaryDetails == null || this.salaryDetails.isEmpty()) - && this.payDetail == null - && (this.paidTimeOff == null || this.paidTimeOff.isEmpty())); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Pay Period:%n%s", this.getPayPeriod().toFieldList())); - outStr.append(String.format(":Employee:%n%s", this.getEmployee().toFieldList())); - outStr.append(String.format(":Employer:%n%s", this.getEmployer().toFieldList())); - outStr - .append( - String.format(":Bank Account Details:%n%s", this.getBankAccountDetails().toFieldList()) - ); - outStr.append(String.format(":Employment:%n%s", this.getEmployment().toFieldList())); - String salaryDetailsSummary = ""; - if (!this.getSalaryDetails().isEmpty()) { - int[] salaryDetailsColSizes = new int[] { 14, 11, 38, 8, 11 }; - salaryDetailsSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(salaryDetailsColSizes, "-")) - + "| Amount " - + "| Base " - + "| Description " - + "| Number " - + "| Rate " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(salaryDetailsColSizes, "=")); - salaryDetailsSummary += SummaryHelper - .arrayToString(this.getSalaryDetails(), salaryDetailsColSizes); - salaryDetailsSummary += String - .format("%n%s", SummaryHelper.lineSeparator(salaryDetailsColSizes, "-")); - } - outStr.append(String.format(":Salary Details: %s%n", salaryDetailsSummary)); - outStr.append(String.format(":Pay Detail:%n%s", this.getPayDetail().toFieldList())); - String paidTimeOffSummary = ""; - if (!this.getPaidTimeOff().isEmpty()) { - int[] paidTimeOffColSizes = new int[] { 11, 8, 13, 11, 11 }; - paidTimeOffSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(paidTimeOffColSizes, "-")) - + "| Accrued " - + "| Period " - + "| Type " - + "| Remaining " - + "| Used " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(paidTimeOffColSizes, "=")); - paidTimeOffSummary += SummaryHelper.arrayToString(this.getPaidTimeOff(), paidTimeOffColSizes); - paidTimeOffSummary += String - .format("%n%s", SummaryHelper.lineSeparator(paidTimeOffColSizes, "-")); - } - outStr.append(String.format(":Paid Time Off: %s%n", paidTimeOffSummary)); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/fr/payslip/PayslipV3Employee.java b/src/main/java/com/mindee/product/fr/payslip/PayslipV3Employee.java deleted file mode 100644 index 4d97365b6..000000000 --- a/src/main/java/com/mindee/product/fr/payslip/PayslipV3Employee.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.mindee.product.fr.payslip; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Information about the employee. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class PayslipV3Employee extends BaseField { - - /** - * The address of the employee. - */ - @JsonProperty("address") - String address; - /** - * The date of birth of the employee. - */ - @JsonProperty("date_of_birth") - String dateOfBirth; - /** - * The first name of the employee. - */ - @JsonProperty("first_name") - String firstName; - /** - * The last name of the employee. - */ - @JsonProperty("last_name") - String lastName; - /** - * The phone number of the employee. - */ - @JsonProperty("phone_number") - String phoneNumber; - /** - * The registration number of the employee. - */ - @JsonProperty("registration_number") - String registrationNumber; - /** - * The social security number of the employee. - */ - @JsonProperty("social_security_number") - String socialSecurityNumber; - - public boolean isEmpty() { - return ((address == null || address.isEmpty()) - && (dateOfBirth == null || dateOfBirth.isEmpty()) - && (firstName == null || firstName.isEmpty()) - && (lastName == null || lastName.isEmpty()) - && (phoneNumber == null || phoneNumber.isEmpty()) - && (registrationNumber == null || registrationNumber.isEmpty()) - && (socialSecurityNumber == null || socialSecurityNumber.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Address: %s%n", printable.get("address")) - + String.format(" :Date of Birth: %s%n", printable.get("dateOfBirth")) - + String.format(" :First Name: %s%n", printable.get("firstName")) - + String.format(" :Last Name: %s%n", printable.get("lastName")) - + String.format(" :Phone Number: %s%n", printable.get("phoneNumber")) - + String.format(" :Registration Number: %s%n", printable.get("registrationNumber")) - + String.format(" :Social Security Number: %s%n", printable.get("socialSecurityNumber")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Address: %s", printable.get("address")) - + String.format(", Date of Birth: %s", printable.get("dateOfBirth")) - + String.format(", First Name: %s", printable.get("firstName")) - + String.format(", Last Name: %s", printable.get("lastName")) - + String.format(", Phone Number: %s", printable.get("phoneNumber")) - + String.format(", Registration Number: %s", printable.get("registrationNumber")) - + String.format(", Social Security Number: %s", printable.get("socialSecurityNumber")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("address", SummaryHelper.formatForDisplay(this.address, null)); - printable.put("dateOfBirth", SummaryHelper.formatForDisplay(this.dateOfBirth, null)); - printable.put("firstName", SummaryHelper.formatForDisplay(this.firstName, null)); - printable.put("lastName", SummaryHelper.formatForDisplay(this.lastName, null)); - printable.put("phoneNumber", SummaryHelper.formatForDisplay(this.phoneNumber, null)); - printable - .put("registrationNumber", SummaryHelper.formatForDisplay(this.registrationNumber, null)); - printable - .put("socialSecurityNumber", SummaryHelper.formatForDisplay(this.socialSecurityNumber, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/payslip/PayslipV3Employer.java b/src/main/java/com/mindee/product/fr/payslip/PayslipV3Employer.java deleted file mode 100644 index 2a1999bb2..000000000 --- a/src/main/java/com/mindee/product/fr/payslip/PayslipV3Employer.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.mindee.product.fr.payslip; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Information about the employer. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class PayslipV3Employer extends BaseField { - - /** - * The address of the employer. - */ - @JsonProperty("address") - String address; - /** - * The company ID of the employer. - */ - @JsonProperty("company_id") - String companyId; - /** - * The site of the company. - */ - @JsonProperty("company_site") - String companySite; - /** - * The NAF code of the employer. - */ - @JsonProperty("naf_code") - String nafCode; - /** - * The name of the employer. - */ - @JsonProperty("name") - String name; - /** - * The phone number of the employer. - */ - @JsonProperty("phone_number") - String phoneNumber; - /** - * The URSSAF number of the employer. - */ - @JsonProperty("urssaf_number") - String urssafNumber; - - public boolean isEmpty() { - return ((address == null || address.isEmpty()) - && (companyId == null || companyId.isEmpty()) - && (companySite == null || companySite.isEmpty()) - && (nafCode == null || nafCode.isEmpty()) - && (name == null || name.isEmpty()) - && (phoneNumber == null || phoneNumber.isEmpty()) - && (urssafNumber == null || urssafNumber.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Address: %s%n", printable.get("address")) - + String.format(" :Company ID: %s%n", printable.get("companyId")) - + String.format(" :Company Site: %s%n", printable.get("companySite")) - + String.format(" :NAF Code: %s%n", printable.get("nafCode")) - + String.format(" :Name: %s%n", printable.get("name")) - + String.format(" :Phone Number: %s%n", printable.get("phoneNumber")) - + String.format(" :URSSAF Number: %s%n", printable.get("urssafNumber")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Address: %s", printable.get("address")) - + String.format(", Company ID: %s", printable.get("companyId")) - + String.format(", Company Site: %s", printable.get("companySite")) - + String.format(", NAF Code: %s", printable.get("nafCode")) - + String.format(", Name: %s", printable.get("name")) - + String.format(", Phone Number: %s", printable.get("phoneNumber")) - + String.format(", URSSAF Number: %s", printable.get("urssafNumber")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("address", SummaryHelper.formatForDisplay(this.address, null)); - printable.put("companyId", SummaryHelper.formatForDisplay(this.companyId, null)); - printable.put("companySite", SummaryHelper.formatForDisplay(this.companySite, null)); - printable.put("nafCode", SummaryHelper.formatForDisplay(this.nafCode, null)); - printable.put("name", SummaryHelper.formatForDisplay(this.name, null)); - printable.put("phoneNumber", SummaryHelper.formatForDisplay(this.phoneNumber, null)); - printable.put("urssafNumber", SummaryHelper.formatForDisplay(this.urssafNumber, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/payslip/PayslipV3Employment.java b/src/main/java/com/mindee/product/fr/payslip/PayslipV3Employment.java deleted file mode 100644 index 3ff48d488..000000000 --- a/src/main/java/com/mindee/product/fr/payslip/PayslipV3Employment.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.mindee.product.fr.payslip; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Information about the employment. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class PayslipV3Employment extends BaseField { - - /** - * The category of the employment. - */ - @JsonProperty("category") - String category; - /** - * The coefficient of the employment. - */ - @JsonProperty("coefficient") - String coefficient; - /** - * The collective agreement of the employment. - */ - @JsonProperty("collective_agreement") - String collectiveAgreement; - /** - * The job title of the employee. - */ - @JsonProperty("job_title") - String jobTitle; - /** - * The position level of the employment. - */ - @JsonProperty("position_level") - String positionLevel; - /** - * The seniority date of the employment. - */ - @JsonProperty("seniority_date") - String seniorityDate; - /** - * The start date of the employment. - */ - @JsonProperty("start_date") - String startDate; - - public boolean isEmpty() { - return ((category == null || category.isEmpty()) - && (coefficient == null || coefficient.isEmpty()) - && (collectiveAgreement == null || collectiveAgreement.isEmpty()) - && (jobTitle == null || jobTitle.isEmpty()) - && (positionLevel == null || positionLevel.isEmpty()) - && (seniorityDate == null || seniorityDate.isEmpty()) - && (startDate == null || startDate.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Category: %s%n", printable.get("category")) - + String.format(" :Coefficient: %s%n", printable.get("coefficient")) - + String.format(" :Collective Agreement: %s%n", printable.get("collectiveAgreement")) - + String.format(" :Job Title: %s%n", printable.get("jobTitle")) - + String.format(" :Position Level: %s%n", printable.get("positionLevel")) - + String.format(" :Seniority Date: %s%n", printable.get("seniorityDate")) - + String.format(" :Start Date: %s%n", printable.get("startDate")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Category: %s", printable.get("category")) - + String.format(", Coefficient: %s", printable.get("coefficient")) - + String.format(", Collective Agreement: %s", printable.get("collectiveAgreement")) - + String.format(", Job Title: %s", printable.get("jobTitle")) - + String.format(", Position Level: %s", printable.get("positionLevel")) - + String.format(", Seniority Date: %s", printable.get("seniorityDate")) - + String.format(", Start Date: %s", printable.get("startDate")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("category", SummaryHelper.formatForDisplay(this.category, null)); - printable.put("coefficient", SummaryHelper.formatForDisplay(this.coefficient, null)); - printable - .put("collectiveAgreement", SummaryHelper.formatForDisplay(this.collectiveAgreement, null)); - printable.put("jobTitle", SummaryHelper.formatForDisplay(this.jobTitle, null)); - printable.put("positionLevel", SummaryHelper.formatForDisplay(this.positionLevel, null)); - printable.put("seniorityDate", SummaryHelper.formatForDisplay(this.seniorityDate, null)); - printable.put("startDate", SummaryHelper.formatForDisplay(this.startDate, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/payslip/PayslipV3PaidTimeOff.java b/src/main/java/com/mindee/product/fr/payslip/PayslipV3PaidTimeOff.java deleted file mode 100644 index f010d9eae..000000000 --- a/src/main/java/com/mindee/product/fr/payslip/PayslipV3PaidTimeOff.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.mindee.product.fr.payslip; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Information about paid time off. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class PayslipV3PaidTimeOff extends BaseField implements LineItemField { - - /** - * The amount of paid time off accrued in the period. - */ - @JsonProperty("accrued") - Double accrued; - /** - * The paid time off period. - */ - @JsonProperty("period") - String period; - /** - * The type of paid time off. - */ - @JsonProperty("pto_type") - String ptoType; - /** - * The remaining amount of paid time off at the end of the period. - */ - @JsonProperty("remaining") - Double remaining; - /** - * The amount of paid time off used in the period. - */ - @JsonProperty("used") - Double used; - - public boolean isEmpty() { - return (accrued == null - && (period == null || period.isEmpty()) - && (ptoType == null || ptoType.isEmpty()) - && remaining == null - && used == null); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("accrued", SummaryHelper.formatAmount(this.accrued)); - printable.put("period", SummaryHelper.formatForDisplay(this.period, 6)); - printable.put("ptoType", SummaryHelper.formatForDisplay(this.ptoType, 11)); - printable.put("remaining", SummaryHelper.formatAmount(this.remaining)); - printable.put("used", SummaryHelper.formatAmount(this.used)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-9s ", printable.get("accrued")) - + String.format("| %-6s ", printable.get("period")) - + String.format("| %-11s ", printable.get("ptoType")) - + String.format("| %-9s ", printable.get("remaining")) - + String.format("| %-9s |", printable.get("used")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Accrued: %s", printable.get("accrued")) - + String.format(", Period: %s", printable.get("period")) - + String.format(", Type: %s", printable.get("ptoType")) - + String.format(", Remaining: %s", printable.get("remaining")) - + String.format(", Used: %s", printable.get("used")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("accrued", SummaryHelper.formatAmount(this.accrued)); - printable.put("period", SummaryHelper.formatForDisplay(this.period, null)); - printable.put("ptoType", SummaryHelper.formatForDisplay(this.ptoType, null)); - printable.put("remaining", SummaryHelper.formatAmount(this.remaining)); - printable.put("used", SummaryHelper.formatAmount(this.used)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/payslip/PayslipV3PayDetail.java b/src/main/java/com/mindee/product/fr/payslip/PayslipV3PayDetail.java deleted file mode 100644 index fc3257089..000000000 --- a/src/main/java/com/mindee/product/fr/payslip/PayslipV3PayDetail.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.mindee.product.fr.payslip; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Detailed information about the pay. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class PayslipV3PayDetail extends BaseField { - - /** - * The gross salary of the employee. - */ - @JsonProperty("gross_salary") - Double grossSalary; - /** - * The year-to-date gross salary of the employee. - */ - @JsonProperty("gross_salary_ytd") - Double grossSalaryYtd; - /** - * The income tax rate of the employee. - */ - @JsonProperty("income_tax_rate") - Double incomeTaxRate; - /** - * The income tax withheld from the employee's pay. - */ - @JsonProperty("income_tax_withheld") - Double incomeTaxWithheld; - /** - * The net paid amount of the employee. - */ - @JsonProperty("net_paid") - Double netPaid; - /** - * The net paid amount before tax of the employee. - */ - @JsonProperty("net_paid_before_tax") - Double netPaidBeforeTax; - /** - * The net taxable amount of the employee. - */ - @JsonProperty("net_taxable") - Double netTaxable; - /** - * The year-to-date net taxable amount of the employee. - */ - @JsonProperty("net_taxable_ytd") - Double netTaxableYtd; - /** - * The total cost to the employer. - */ - @JsonProperty("total_cost_employer") - Double totalCostEmployer; - /** - * The total taxes and deductions of the employee. - */ - @JsonProperty("total_taxes_and_deductions") - Double totalTaxesAndDeductions; - - public boolean isEmpty() { - return (grossSalary == null - && grossSalaryYtd == null - && incomeTaxRate == null - && incomeTaxWithheld == null - && netPaid == null - && netPaidBeforeTax == null - && netTaxable == null - && netTaxableYtd == null - && totalCostEmployer == null - && totalTaxesAndDeductions == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Gross Salary: %s%n", printable.get("grossSalary")) - + String.format(" :Gross Salary YTD: %s%n", printable.get("grossSalaryYtd")) - + String.format(" :Income Tax Rate: %s%n", printable.get("incomeTaxRate")) - + String.format(" :Income Tax Withheld: %s%n", printable.get("incomeTaxWithheld")) - + String.format(" :Net Paid: %s%n", printable.get("netPaid")) - + String.format(" :Net Paid Before Tax: %s%n", printable.get("netPaidBeforeTax")) - + String.format(" :Net Taxable: %s%n", printable.get("netTaxable")) - + String.format(" :Net Taxable YTD: %s%n", printable.get("netTaxableYtd")) - + String.format(" :Total Cost Employer: %s%n", printable.get("totalCostEmployer")) - + String - .format(" :Total Taxes and Deductions: %s%n", printable.get("totalTaxesAndDeductions")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Gross Salary: %s", printable.get("grossSalary")) - + String.format(", Gross Salary YTD: %s", printable.get("grossSalaryYtd")) - + String.format(", Income Tax Rate: %s", printable.get("incomeTaxRate")) - + String.format(", Income Tax Withheld: %s", printable.get("incomeTaxWithheld")) - + String.format(", Net Paid: %s", printable.get("netPaid")) - + String.format(", Net Paid Before Tax: %s", printable.get("netPaidBeforeTax")) - + String.format(", Net Taxable: %s", printable.get("netTaxable")) - + String.format(", Net Taxable YTD: %s", printable.get("netTaxableYtd")) - + String.format(", Total Cost Employer: %s", printable.get("totalCostEmployer")) - + String.format(", Total Taxes and Deductions: %s", printable.get("totalTaxesAndDeductions")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("grossSalary", SummaryHelper.formatAmount(this.grossSalary)); - printable.put("grossSalaryYtd", SummaryHelper.formatAmount(this.grossSalaryYtd)); - printable.put("incomeTaxRate", SummaryHelper.formatAmount(this.incomeTaxRate)); - printable.put("incomeTaxWithheld", SummaryHelper.formatAmount(this.incomeTaxWithheld)); - printable.put("netPaid", SummaryHelper.formatAmount(this.netPaid)); - printable.put("netPaidBeforeTax", SummaryHelper.formatAmount(this.netPaidBeforeTax)); - printable.put("netTaxable", SummaryHelper.formatAmount(this.netTaxable)); - printable.put("netTaxableYtd", SummaryHelper.formatAmount(this.netTaxableYtd)); - printable.put("totalCostEmployer", SummaryHelper.formatAmount(this.totalCostEmployer)); - printable - .put("totalTaxesAndDeductions", SummaryHelper.formatAmount(this.totalTaxesAndDeductions)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/payslip/PayslipV3PayPeriod.java b/src/main/java/com/mindee/product/fr/payslip/PayslipV3PayPeriod.java deleted file mode 100644 index 3ecd7dd97..000000000 --- a/src/main/java/com/mindee/product/fr/payslip/PayslipV3PayPeriod.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.mindee.product.fr.payslip; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Information about the pay period. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class PayslipV3PayPeriod extends BaseField { - - /** - * The end date of the pay period. - */ - @JsonProperty("end_date") - String endDate; - /** - * The month of the pay period. - */ - @JsonProperty("month") - String month; - /** - * The date of payment for the pay period. - */ - @JsonProperty("payment_date") - String paymentDate; - /** - * The start date of the pay period. - */ - @JsonProperty("start_date") - String startDate; - /** - * The year of the pay period. - */ - @JsonProperty("year") - String year; - - public boolean isEmpty() { - return ((endDate == null || endDate.isEmpty()) - && (month == null || month.isEmpty()) - && (paymentDate == null || paymentDate.isEmpty()) - && (startDate == null || startDate.isEmpty()) - && (year == null || year.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :End Date: %s%n", printable.get("endDate")) - + String.format(" :Month: %s%n", printable.get("month")) - + String.format(" :Payment Date: %s%n", printable.get("paymentDate")) - + String.format(" :Start Date: %s%n", printable.get("startDate")) - + String.format(" :Year: %s%n", printable.get("year")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("End Date: %s", printable.get("endDate")) - + String.format(", Month: %s", printable.get("month")) - + String.format(", Payment Date: %s", printable.get("paymentDate")) - + String.format(", Start Date: %s", printable.get("startDate")) - + String.format(", Year: %s", printable.get("year")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("endDate", SummaryHelper.formatForDisplay(this.endDate, null)); - printable.put("month", SummaryHelper.formatForDisplay(this.month, null)); - printable.put("paymentDate", SummaryHelper.formatForDisplay(this.paymentDate, null)); - printable.put("startDate", SummaryHelper.formatForDisplay(this.startDate, null)); - printable.put("year", SummaryHelper.formatForDisplay(this.year, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/fr/payslip/PayslipV3SalaryDetail.java b/src/main/java/com/mindee/product/fr/payslip/PayslipV3SalaryDetail.java deleted file mode 100644 index bbef3d76d..000000000 --- a/src/main/java/com/mindee/product/fr/payslip/PayslipV3SalaryDetail.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.mindee.product.fr.payslip; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Detailed information about the earnings. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class PayslipV3SalaryDetail extends BaseField implements LineItemField { - - /** - * The amount of the earning. - */ - @JsonProperty("amount") - Double amount; - /** - * The base rate value of the earning. - */ - @JsonProperty("base") - Double base; - /** - * The description of the earnings. - */ - @JsonProperty("description") - String description; - /** - * The number of units in the earning. - */ - @JsonProperty("number") - Double number; - /** - * The rate of the earning. - */ - @JsonProperty("rate") - Double rate; - - public boolean isEmpty() { - return (amount == null - && base == null - && (description == null || description.isEmpty()) - && number == null - && rate == null); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("amount", SummaryHelper.formatAmount(this.amount)); - printable.put("base", SummaryHelper.formatAmount(this.base)); - printable.put("description", SummaryHelper.formatForDisplay(this.description, 36)); - printable.put("number", SummaryHelper.formatAmount(this.number)); - printable.put("rate", SummaryHelper.formatAmount(this.rate)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-12s ", printable.get("amount")) - + String.format("| %-9s ", printable.get("base")) - + String.format("| %-36s ", printable.get("description")) - + String.format("| %-6s ", printable.get("number")) - + String.format("| %-9s |", printable.get("rate")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Amount: %s", printable.get("amount")) - + String.format(", Base: %s", printable.get("base")) - + String.format(", Description: %s", printable.get("description")) - + String.format(", Number: %s", printable.get("number")) - + String.format(", Rate: %s", printable.get("rate")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("amount", SummaryHelper.formatAmount(this.amount)); - printable.put("base", SummaryHelper.formatAmount(this.base)); - printable.put("description", SummaryHelper.formatForDisplay(this.description, null)); - printable.put("number", SummaryHelper.formatAmount(this.number)); - printable.put("rate", SummaryHelper.formatAmount(this.rate)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1.java deleted file mode 100644 index ca339d41f..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Nutrition Facts Label API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "nutrition_facts", version = "1") -public class NutritionFactsLabelV1 - extends Inference { -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1AddedSugar.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1AddedSugar.java deleted file mode 100644 index 956120943..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1AddedSugar.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The amount of added sugars in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1AddedSugar extends BaseField { - - /** - * DVs are the recommended amounts of added sugars to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of added sugars per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of added sugars per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - - public boolean isEmpty() { - return (dailyValue == null && per100G == null && perServing == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Calorie.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Calorie.java deleted file mode 100644 index 9aa468537..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Calorie.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The amount of calories in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1Calorie extends BaseField { - - /** - * DVs are the recommended amounts of calories to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of calories per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of calories per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - - public boolean isEmpty() { - return (dailyValue == null && per100G == null && perServing == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Cholesterol.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Cholesterol.java deleted file mode 100644 index 90350a563..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Cholesterol.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The amount of cholesterol in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1Cholesterol extends BaseField { - - /** - * DVs are the recommended amounts of cholesterol to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of cholesterol per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of cholesterol per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - - public boolean isEmpty() { - return (dailyValue == null && per100G == null && perServing == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1DietaryFiber.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1DietaryFiber.java deleted file mode 100644 index 2428c48b0..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1DietaryFiber.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The amount of dietary fiber in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1DietaryFiber extends BaseField { - - /** - * DVs are the recommended amounts of dietary fiber to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of dietary fiber per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of dietary fiber per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - - public boolean isEmpty() { - return (dailyValue == null && per100G == null && perServing == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Document.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Document.java deleted file mode 100644 index 87c69ef92..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Document.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.AmountField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Nutrition Facts Label API version 1.0 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1Document extends Prediction { - - /** - * The amount of added sugars in the product. - */ - @JsonProperty("added_sugars") - protected NutritionFactsLabelV1AddedSugar addedSugars; - /** - * The amount of calories in the product. - */ - @JsonProperty("calories") - protected NutritionFactsLabelV1Calorie calories; - /** - * The amount of cholesterol in the product. - */ - @JsonProperty("cholesterol") - protected NutritionFactsLabelV1Cholesterol cholesterol; - /** - * The amount of dietary fiber in the product. - */ - @JsonProperty("dietary_fiber") - protected NutritionFactsLabelV1DietaryFiber dietaryFiber; - /** - * The amount of nutrients in the product. - */ - @JsonProperty("nutrients") - protected List nutrients = new ArrayList<>(); - /** - * The amount of protein in the product. - */ - @JsonProperty("protein") - protected NutritionFactsLabelV1Protein protein; - /** - * The amount of saturated fat in the product. - */ - @JsonProperty("saturated_fat") - protected NutritionFactsLabelV1SaturatedFat saturatedFat; - /** - * The number of servings in each box of the product. - */ - @JsonProperty("serving_per_box") - protected AmountField servingPerBox; - /** - * The size of a single serving of the product. - */ - @JsonProperty("serving_size") - protected NutritionFactsLabelV1ServingSize servingSize; - /** - * The amount of sodium in the product. - */ - @JsonProperty("sodium") - protected NutritionFactsLabelV1Sodium sodium; - /** - * The total amount of carbohydrates in the product. - */ - @JsonProperty("total_carbohydrate") - protected NutritionFactsLabelV1TotalCarbohydrate totalCarbohydrate; - /** - * The total amount of fat in the product. - */ - @JsonProperty("total_fat") - protected NutritionFactsLabelV1TotalFat totalFat; - /** - * The total amount of sugars in the product. - */ - @JsonProperty("total_sugars") - protected NutritionFactsLabelV1TotalSugar totalSugars; - /** - * The amount of trans fat in the product. - */ - @JsonProperty("trans_fat") - protected NutritionFactsLabelV1TransFat transFat; - - @Override - public boolean isEmpty() { - return (this.servingPerBox == null - && this.servingSize == null - && this.calories == null - && this.totalFat == null - && this.saturatedFat == null - && this.transFat == null - && this.cholesterol == null - && this.totalCarbohydrate == null - && this.dietaryFiber == null - && this.totalSugars == null - && this.addedSugars == null - && this.protein == null - && this.sodium == null - && (this.nutrients == null || this.nutrients.isEmpty())); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Serving per Box: %s%n", this.getServingPerBox())); - outStr.append(String.format(":Serving Size:%n%s", this.getServingSize().toFieldList())); - outStr.append(String.format(":Calories:%n%s", this.getCalories().toFieldList())); - outStr.append(String.format(":Total Fat:%n%s", this.getTotalFat().toFieldList())); - outStr.append(String.format(":Saturated Fat:%n%s", this.getSaturatedFat().toFieldList())); - outStr.append(String.format(":Trans Fat:%n%s", this.getTransFat().toFieldList())); - outStr.append(String.format(":Cholesterol:%n%s", this.getCholesterol().toFieldList())); - outStr - .append(String.format(":Total Carbohydrate:%n%s", this.getTotalCarbohydrate().toFieldList())); - outStr.append(String.format(":Dietary Fiber:%n%s", this.getDietaryFiber().toFieldList())); - outStr.append(String.format(":Total Sugars:%n%s", this.getTotalSugars().toFieldList())); - outStr.append(String.format(":Added Sugars:%n%s", this.getAddedSugars().toFieldList())); - outStr.append(String.format(":Protein:%n%s", this.getProtein().toFieldList())); - outStr.append(String.format(":sodium:%n%s", this.getSodium().toFieldList())); - String nutrientsSummary = ""; - if (!this.getNutrients().isEmpty()) { - int[] nutrientsColSizes = new int[] { 13, 22, 10, 13, 6 }; - nutrientsSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(nutrientsColSizes, "-")) - + "| Daily Value " - + "| Name " - + "| Per 100g " - + "| Per Serving " - + "| Unit " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(nutrientsColSizes, "=")); - nutrientsSummary += SummaryHelper.arrayToString(this.getNutrients(), nutrientsColSizes); - nutrientsSummary += String - .format("%n%s", SummaryHelper.lineSeparator(nutrientsColSizes, "-")); - } - outStr.append(String.format(":nutrients: %s%n", nutrientsSummary)); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Nutrient.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Nutrient.java deleted file mode 100644 index 5a2e4abff..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Nutrient.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The amount of nutrients in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1Nutrient extends BaseField implements LineItemField { - - /** - * DVs are the recommended amounts of nutrients to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The name of nutrients of the product. - */ - @JsonProperty("name") - String name; - /** - * The amount of nutrients per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of nutrients per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - /** - * The unit of measurement for the amount of nutrients. - */ - @JsonProperty("unit") - String unit; - - public boolean isEmpty() { - return (dailyValue == null - && (name == null || name.isEmpty()) - && per100G == null - && perServing == null - && (unit == null || unit.isEmpty())); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("name", SummaryHelper.formatForDisplay(this.name, 20)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - printable.put("unit", SummaryHelper.formatForDisplay(this.unit, null)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-11s ", printable.get("dailyValue")) - + String.format("| %-20s ", printable.get("name")) - + String.format("| %-8s ", printable.get("per100G")) - + String.format("| %-11s ", printable.get("perServing")) - + String.format("| %-4s |", printable.get("unit")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Name: %s", printable.get("name")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")) - + String.format(", Unit: %s", printable.get("unit")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("name", SummaryHelper.formatForDisplay(this.name, null)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - printable.put("unit", SummaryHelper.formatForDisplay(this.unit, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Protein.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Protein.java deleted file mode 100644 index 000185c4a..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Protein.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The amount of protein in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1Protein extends BaseField { - - /** - * DVs are the recommended amounts of protein to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of protein per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of protein per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - - public boolean isEmpty() { - return (dailyValue == null && per100G == null && perServing == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1SaturatedFat.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1SaturatedFat.java deleted file mode 100644 index 871357dc0..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1SaturatedFat.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The amount of saturated fat in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1SaturatedFat extends BaseField { - - /** - * DVs are the recommended amounts of saturated fat to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of saturated fat per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of saturated fat per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - - public boolean isEmpty() { - return (dailyValue == null && per100G == null && perServing == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1ServingSize.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1ServingSize.java deleted file mode 100644 index b52d5101f..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1ServingSize.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The size of a single serving of the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1ServingSize extends BaseField { - - /** - * The amount of a single serving. - */ - @JsonProperty("amount") - Double amount; - /** - * The unit for the amount of a single serving. - */ - @JsonProperty("unit") - String unit; - - public boolean isEmpty() { - return (amount == null && (unit == null || unit.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Amount: %s%n", printable.get("amount")) - + String.format(" :Unit: %s%n", printable.get("unit")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Amount: %s", printable.get("amount")) - + String.format(", Unit: %s", printable.get("unit")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("amount", SummaryHelper.formatAmount(this.amount)); - printable.put("unit", SummaryHelper.formatForDisplay(this.unit, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Sodium.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Sodium.java deleted file mode 100644 index 0050056bc..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Sodium.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The amount of sodium in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1Sodium extends BaseField { - - /** - * DVs are the recommended amounts of sodium to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of sodium per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of sodium per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - /** - * The unit of measurement for the amount of sodium. - */ - @JsonProperty("unit") - String unit; - - public boolean isEmpty() { - return (dailyValue == null - && per100G == null - && perServing == null - && (unit == null || unit.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")) - + String.format(" :Unit: %s%n", printable.get("unit")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")) - + String.format(", Unit: %s", printable.get("unit")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - printable.put("unit", SummaryHelper.formatForDisplay(this.unit, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalCarbohydrate.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalCarbohydrate.java deleted file mode 100644 index efb97e0c6..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalCarbohydrate.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The total amount of carbohydrates in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1TotalCarbohydrate extends BaseField { - - /** - * DVs are the recommended amounts of total carbohydrates to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of total carbohydrates per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of total carbohydrates per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - - public boolean isEmpty() { - return (dailyValue == null && per100G == null && perServing == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalFat.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalFat.java deleted file mode 100644 index ae6da0b5c..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalFat.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The total amount of fat in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1TotalFat extends BaseField { - - /** - * DVs are the recommended amounts of total fat to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of total fat per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of total fat per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - - public boolean isEmpty() { - return (dailyValue == null && per100G == null && perServing == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalSugar.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalSugar.java deleted file mode 100644 index ab7a55160..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TotalSugar.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The total amount of sugars in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1TotalSugar extends BaseField { - - /** - * DVs are the recommended amounts of total sugars to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of total sugars per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of total sugars per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - - public boolean isEmpty() { - return (dailyValue == null && per100G == null && perServing == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TransFat.java b/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TransFat.java deleted file mode 100644 index cbbe14a4b..000000000 --- a/src/main/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1TransFat.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The amount of trans fat in the product. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class NutritionFactsLabelV1TransFat extends BaseField { - - /** - * DVs are the recommended amounts of trans fat to consume or not to exceed each day. - */ - @JsonProperty("daily_value") - Double dailyValue; - /** - * The amount of trans fat per 100g of the product. - */ - @JsonProperty("per_100g") - Double per100G; - /** - * The amount of trans fat per serving of the product. - */ - @JsonProperty("per_serving") - Double perServing; - - public boolean isEmpty() { - return (dailyValue == null && per100G == null && perServing == null); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :Daily Value: %s%n", printable.get("dailyValue")) - + String.format(" :Per 100g: %s%n", printable.get("per100G")) - + String.format(" :Per Serving: %s%n", printable.get("perServing")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Daily Value: %s", printable.get("dailyValue")) - + String.format(", Per 100g: %s", printable.get("per100G")) - + String.format(", Per Serving: %s", printable.get("perServing")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("dailyValue", SummaryHelper.formatAmount(this.dailyValue)); - printable.put("per100G", SummaryHelper.formatAmount(this.per100G)); - printable.put("perServing", SummaryHelper.formatAmount(this.perServing)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1.java b/src/main/java/com/mindee/product/resume/ResumeV1.java deleted file mode 100644 index c0b5d437a..000000000 --- a/src/main/java/com/mindee/product/resume/ResumeV1.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mindee.product.resume; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Resume API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "resume", version = "1") -public class ResumeV1 extends Inference { -} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Certificate.java b/src/main/java/com/mindee/product/resume/ResumeV1Certificate.java deleted file mode 100644 index 7d49e7ddd..000000000 --- a/src/main/java/com/mindee/product/resume/ResumeV1Certificate.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.mindee.product.resume; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The list of certificates obtained by the candidate. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class ResumeV1Certificate extends BaseField implements LineItemField { - - /** - * The grade obtained for the certificate. - */ - @JsonProperty("grade") - String grade; - /** - * The name of certification. - */ - @JsonProperty("name") - String name; - /** - * The organization or institution that issued the certificate. - */ - @JsonProperty("provider") - String provider; - /** - * The year when a certificate was issued or received. - */ - @JsonProperty("year") - String year; - - public boolean isEmpty() { - return ((grade == null || grade.isEmpty()) - && (name == null || name.isEmpty()) - && (provider == null || provider.isEmpty()) - && (year == null || year.isEmpty())); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("grade", SummaryHelper.formatForDisplay(this.grade, 10)); - printable.put("name", SummaryHelper.formatForDisplay(this.name, 30)); - printable.put("provider", SummaryHelper.formatForDisplay(this.provider, 25)); - printable.put("year", SummaryHelper.formatForDisplay(this.year, null)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-10s ", printable.get("grade")) - + String.format("| %-30s ", printable.get("name")) - + String.format("| %-25s ", printable.get("provider")) - + String.format("| %-4s |", printable.get("year")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Grade: %s", printable.get("grade")) - + String.format(", Name: %s", printable.get("name")) - + String.format(", Provider: %s", printable.get("provider")) - + String.format(", Year: %s", printable.get("year")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("grade", SummaryHelper.formatForDisplay(this.grade, null)); - printable.put("name", SummaryHelper.formatForDisplay(this.name, null)); - printable.put("provider", SummaryHelper.formatForDisplay(this.provider, null)); - printable.put("year", SummaryHelper.formatForDisplay(this.year, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Document.java b/src/main/java/com/mindee/product/resume/ResumeV1Document.java deleted file mode 100644 index ac9d1728a..000000000 --- a/src/main/java/com/mindee/product/resume/ResumeV1Document.java +++ /dev/null @@ -1,233 +0,0 @@ -package com.mindee.product.resume; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.parsing.standard.StringField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Resume API version 1.2 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class ResumeV1Document extends Prediction { - - /** - * The location information of the candidate, including city, state, and country. - */ - @JsonProperty("address") - protected StringField address; - /** - * The list of certificates obtained by the candidate. - */ - @JsonProperty("certificates") - protected List certificates = new ArrayList<>(); - /** - * The ISO 639 code of the language in which the document is written. - */ - @JsonProperty("document_language") - protected StringField documentLanguage; - /** - * The type of the document sent. - */ - @JsonProperty("document_type") - protected ClassificationField documentType; - /** - * The list of the candidate's educational background. - */ - @JsonProperty("education") - protected List education = new ArrayList<>(); - /** - * The email address of the candidate. - */ - @JsonProperty("email_address") - protected StringField emailAddress; - /** - * The candidate's first or given names. - */ - @JsonProperty("given_names") - protected List givenNames = new ArrayList<>(); - /** - * The list of the candidate's technical abilities and knowledge. - */ - @JsonProperty("hard_skills") - protected List hardSkills = new ArrayList<>(); - /** - * The position that the candidate is applying for. - */ - @JsonProperty("job_applied") - protected StringField jobApplied; - /** - * The list of languages that the candidate is proficient in. - */ - @JsonProperty("languages") - protected List languages = new ArrayList<>(); - /** - * The ISO 3166 code for the country of citizenship of the candidate. - */ - @JsonProperty("nationality") - protected StringField nationality; - /** - * The phone number of the candidate. - */ - @JsonProperty("phone_number") - protected StringField phoneNumber; - /** - * The candidate's current profession. - */ - @JsonProperty("profession") - protected StringField profession; - /** - * The list of the candidate's professional experiences. - */ - @JsonProperty("professional_experiences") - protected List professionalExperiences = new ArrayList<>(); - /** - * The list of social network profiles of the candidate. - */ - @JsonProperty("social_networks_urls") - protected List socialNetworksUrls = new ArrayList<>(); - /** - * The list of the candidate's interpersonal and communication abilities. - */ - @JsonProperty("soft_skills") - protected List softSkills = new ArrayList<>(); - /** - * The candidate's last names. - */ - @JsonProperty("surnames") - protected List surnames = new ArrayList<>(); - - @Override - public boolean isEmpty() { - return (this.documentLanguage == null - && this.documentType == null - && (this.givenNames == null || this.givenNames.isEmpty()) - && (this.surnames == null || this.surnames.isEmpty()) - && this.nationality == null - && this.emailAddress == null - && this.phoneNumber == null - && this.address == null - && (this.socialNetworksUrls == null || this.socialNetworksUrls.isEmpty()) - && this.profession == null - && this.jobApplied == null - && (this.languages == null || this.languages.isEmpty()) - && (this.hardSkills == null || this.hardSkills.isEmpty()) - && (this.softSkills == null || this.softSkills.isEmpty()) - && (this.education == null || this.education.isEmpty()) - && (this.professionalExperiences == null || this.professionalExperiences.isEmpty()) - && (this.certificates == null || this.certificates.isEmpty())); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Document Language: %s%n", this.getDocumentLanguage())); - outStr.append(String.format(":Document Type: %s%n", this.getDocumentType())); - String givenNames = SummaryHelper.arrayToString(this.getGivenNames(), "%n "); - outStr.append(String.format(":Given Names: %s%n", givenNames)); - String surnames = SummaryHelper.arrayToString(this.getSurnames(), "%n "); - outStr.append(String.format(":Surnames: %s%n", surnames)); - outStr.append(String.format(":Nationality: %s%n", this.getNationality())); - outStr.append(String.format(":Email Address: %s%n", this.getEmailAddress())); - outStr.append(String.format(":Phone Number: %s%n", this.getPhoneNumber())); - outStr.append(String.format(":Address: %s%n", this.getAddress())); - String socialNetworksUrlsSummary = ""; - if (!this.getSocialNetworksUrls().isEmpty()) { - int[] socialNetworksUrlsColSizes = new int[] { 22, 52 }; - socialNetworksUrlsSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(socialNetworksUrlsColSizes, "-")) - + "| Name " - + "| URL " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(socialNetworksUrlsColSizes, "=")); - socialNetworksUrlsSummary += SummaryHelper - .arrayToString(this.getSocialNetworksUrls(), socialNetworksUrlsColSizes); - socialNetworksUrlsSummary += String - .format("%n%s", SummaryHelper.lineSeparator(socialNetworksUrlsColSizes, "-")); - } - outStr.append(String.format(":Social Networks: %s%n", socialNetworksUrlsSummary)); - outStr.append(String.format(":Profession: %s%n", this.getProfession())); - outStr.append(String.format(":Job Applied: %s%n", this.getJobApplied())); - String languagesSummary = ""; - if (!this.getLanguages().isEmpty()) { - int[] languagesColSizes = new int[] { 10, 22 }; - languagesSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(languagesColSizes, "-")) - + "| Language " - + "| Level " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(languagesColSizes, "=")); - languagesSummary += SummaryHelper.arrayToString(this.getLanguages(), languagesColSizes); - languagesSummary += String - .format("%n%s", SummaryHelper.lineSeparator(languagesColSizes, "-")); - } - outStr.append(String.format(":Languages: %s%n", languagesSummary)); - String hardSkills = SummaryHelper.arrayToString(this.getHardSkills(), "%n "); - outStr.append(String.format(":Hard Skills: %s%n", hardSkills)); - String softSkills = SummaryHelper.arrayToString(this.getSoftSkills(), "%n "); - outStr.append(String.format(":Soft Skills: %s%n", softSkills)); - String educationSummary = ""; - if (!this.getEducation().isEmpty()) { - int[] educationColSizes = new int[] { 17, 27, 11, 10, 27, 13, 12 }; - educationSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(educationColSizes, "-")) - + "| Domain " - + "| Degree " - + "| End Month " - + "| End Year " - + "| School " - + "| Start Month " - + "| Start Year " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(educationColSizes, "=")); - educationSummary += SummaryHelper.arrayToString(this.getEducation(), educationColSizes); - educationSummary += String - .format("%n%s", SummaryHelper.lineSeparator(educationColSizes, "-")); - } - outStr.append(String.format(":Education: %s%n", educationSummary)); - String professionalExperiencesSummary = ""; - if (!this.getProfessionalExperiences().isEmpty()) { - int[] professionalExperiencesColSizes = new int[] { 17, 12, 38, 27, 11, 10, 22, 13, 12 }; - professionalExperiencesSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(professionalExperiencesColSizes, "-")) - + "| Contract Type " - + "| Department " - + "| Description " - + "| Employer " - + "| End Month " - + "| End Year " - + "| Role " - + "| Start Month " - + "| Start Year " - + String - .format("|%n%s%n ", SummaryHelper.lineSeparator(professionalExperiencesColSizes, "=")); - professionalExperiencesSummary += SummaryHelper - .arrayToString(this.getProfessionalExperiences(), professionalExperiencesColSizes); - professionalExperiencesSummary += String - .format("%n%s", SummaryHelper.lineSeparator(professionalExperiencesColSizes, "-")); - } - outStr.append(String.format(":Professional Experiences: %s%n", professionalExperiencesSummary)); - String certificatesSummary = ""; - if (!this.getCertificates().isEmpty()) { - int[] certificatesColSizes = new int[] { 12, 32, 27, 6 }; - certificatesSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(certificatesColSizes, "-")) - + "| Grade " - + "| Name " - + "| Provider " - + "| Year " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(certificatesColSizes, "=")); - certificatesSummary += SummaryHelper - .arrayToString(this.getCertificates(), certificatesColSizes); - certificatesSummary += String - .format("%n%s", SummaryHelper.lineSeparator(certificatesColSizes, "-")); - } - outStr.append(String.format(":Certificates: %s%n", certificatesSummary)); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Education.java b/src/main/java/com/mindee/product/resume/ResumeV1Education.java deleted file mode 100644 index a3c32c8c6..000000000 --- a/src/main/java/com/mindee/product/resume/ResumeV1Education.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.mindee.product.resume; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The list of the candidate's educational background. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class ResumeV1Education extends BaseField implements LineItemField { - - /** - * The area of study or specialization. - */ - @JsonProperty("degree_domain") - String degreeDomain; - /** - * The type of degree obtained, such as Bachelor's, Master's, or Doctorate. - */ - @JsonProperty("degree_type") - String degreeType; - /** - * The month when the education program or course was completed. - */ - @JsonProperty("end_month") - String endMonth; - /** - * The year when the education program or course was completed. - */ - @JsonProperty("end_year") - String endYear; - /** - * The name of the school. - */ - @JsonProperty("school") - String school; - /** - * The month when the education program or course began. - */ - @JsonProperty("start_month") - String startMonth; - /** - * The year when the education program or course began. - */ - @JsonProperty("start_year") - String startYear; - - public boolean isEmpty() { - return ((degreeDomain == null || degreeDomain.isEmpty()) - && (degreeType == null || degreeType.isEmpty()) - && (endMonth == null || endMonth.isEmpty()) - && (endYear == null || endYear.isEmpty()) - && (school == null || school.isEmpty()) - && (startMonth == null || startMonth.isEmpty()) - && (startYear == null || startYear.isEmpty())); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("degreeDomain", SummaryHelper.formatForDisplay(this.degreeDomain, 15)); - printable.put("degreeType", SummaryHelper.formatForDisplay(this.degreeType, 25)); - printable.put("endMonth", SummaryHelper.formatForDisplay(this.endMonth, null)); - printable.put("endYear", SummaryHelper.formatForDisplay(this.endYear, null)); - printable.put("school", SummaryHelper.formatForDisplay(this.school, 25)); - printable.put("startMonth", SummaryHelper.formatForDisplay(this.startMonth, null)); - printable.put("startYear", SummaryHelper.formatForDisplay(this.startYear, null)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-15s ", printable.get("degreeDomain")) - + String.format("| %-25s ", printable.get("degreeType")) - + String.format("| %-9s ", printable.get("endMonth")) - + String.format("| %-8s ", printable.get("endYear")) - + String.format("| %-25s ", printable.get("school")) - + String.format("| %-11s ", printable.get("startMonth")) - + String.format("| %-10s |", printable.get("startYear")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Domain: %s", printable.get("degreeDomain")) - + String.format(", Degree: %s", printable.get("degreeType")) - + String.format(", End Month: %s", printable.get("endMonth")) - + String.format(", End Year: %s", printable.get("endYear")) - + String.format(", School: %s", printable.get("school")) - + String.format(", Start Month: %s", printable.get("startMonth")) - + String.format(", Start Year: %s", printable.get("startYear")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("degreeDomain", SummaryHelper.formatForDisplay(this.degreeDomain, null)); - printable.put("degreeType", SummaryHelper.formatForDisplay(this.degreeType, null)); - printable.put("endMonth", SummaryHelper.formatForDisplay(this.endMonth, null)); - printable.put("endYear", SummaryHelper.formatForDisplay(this.endYear, null)); - printable.put("school", SummaryHelper.formatForDisplay(this.school, null)); - printable.put("startMonth", SummaryHelper.formatForDisplay(this.startMonth, null)); - printable.put("startYear", SummaryHelper.formatForDisplay(this.startYear, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Language.java b/src/main/java/com/mindee/product/resume/ResumeV1Language.java deleted file mode 100644 index b097f3750..000000000 --- a/src/main/java/com/mindee/product/resume/ResumeV1Language.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.mindee.product.resume; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The list of languages that the candidate is proficient in. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class ResumeV1Language extends BaseField implements LineItemField { - - /** - * The language's ISO 639 code. - */ - @JsonProperty("language") - String language; - /** - * The candidate's level for the language. - */ - @JsonProperty("level") - String level; - - public boolean isEmpty() { - return ((language == null || language.isEmpty()) && (level == null || level.isEmpty())); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("language", SummaryHelper.formatForDisplay(this.language, null)); - printable.put("level", SummaryHelper.formatForDisplay(this.level, 20)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-8s ", printable.get("language")) - + String.format("| %-20s |", printable.get("level")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Language: %s", printable.get("language")) - + String.format(", Level: %s", printable.get("level")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("language", SummaryHelper.formatForDisplay(this.language, null)); - printable.put("level", SummaryHelper.formatForDisplay(this.level, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java b/src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java deleted file mode 100644 index b7cb1d29f..000000000 --- a/src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.mindee.product.resume; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The list of the candidate's professional experiences. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class ResumeV1ProfessionalExperience extends BaseField implements LineItemField { - - /** - * The type of contract for the professional experience. - */ - @JsonProperty("contract_type") - String contractType; - /** - * The specific department or division within the company. - */ - @JsonProperty("department") - String department; - /** - * The description of the professional experience as written in the document. - */ - @JsonProperty("description") - String description; - /** - * The name of the company or organization. - */ - @JsonProperty("employer") - String employer; - /** - * The month when the professional experience ended. - */ - @JsonProperty("end_month") - String endMonth; - /** - * The year when the professional experience ended. - */ - @JsonProperty("end_year") - String endYear; - /** - * The position or job title held by the candidate. - */ - @JsonProperty("role") - String role; - /** - * The month when the professional experience began. - */ - @JsonProperty("start_month") - String startMonth; - /** - * The year when the professional experience began. - */ - @JsonProperty("start_year") - String startYear; - - public boolean isEmpty() { - return ((contractType == null || contractType.isEmpty()) - && (department == null || department.isEmpty()) - && (description == null || description.isEmpty()) - && (employer == null || employer.isEmpty()) - && (endMonth == null || endMonth.isEmpty()) - && (endYear == null || endYear.isEmpty()) - && (role == null || role.isEmpty()) - && (startMonth == null || startMonth.isEmpty()) - && (startYear == null || startYear.isEmpty())); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("contractType", SummaryHelper.formatForDisplay(this.contractType, 15)); - printable.put("department", SummaryHelper.formatForDisplay(this.department, 10)); - printable.put("description", SummaryHelper.formatForDisplay(this.description, 36)); - printable.put("employer", SummaryHelper.formatForDisplay(this.employer, 25)); - printable.put("endMonth", SummaryHelper.formatForDisplay(this.endMonth, null)); - printable.put("endYear", SummaryHelper.formatForDisplay(this.endYear, null)); - printable.put("role", SummaryHelper.formatForDisplay(this.role, 20)); - printable.put("startMonth", SummaryHelper.formatForDisplay(this.startMonth, null)); - printable.put("startYear", SummaryHelper.formatForDisplay(this.startYear, null)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-15s ", printable.get("contractType")) - + String.format("| %-10s ", printable.get("department")) - + String.format("| %-36s ", printable.get("description")) - + String.format("| %-25s ", printable.get("employer")) - + String.format("| %-9s ", printable.get("endMonth")) - + String.format("| %-8s ", printable.get("endYear")) - + String.format("| %-20s ", printable.get("role")) - + String.format("| %-11s ", printable.get("startMonth")) - + String.format("| %-10s |", printable.get("startYear")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Contract Type: %s", printable.get("contractType")) - + String.format(", Department: %s", printable.get("department")) - + String.format(", Description: %s", printable.get("description")) - + String.format(", Employer: %s", printable.get("employer")) - + String.format(", End Month: %s", printable.get("endMonth")) - + String.format(", End Year: %s", printable.get("endYear")) - + String.format(", Role: %s", printable.get("role")) - + String.format(", Start Month: %s", printable.get("startMonth")) - + String.format(", Start Year: %s", printable.get("startYear")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("contractType", SummaryHelper.formatForDisplay(this.contractType, null)); - printable.put("department", SummaryHelper.formatForDisplay(this.department, null)); - printable.put("description", SummaryHelper.formatForDisplay(this.description, null)); - printable.put("employer", SummaryHelper.formatForDisplay(this.employer, null)); - printable.put("endMonth", SummaryHelper.formatForDisplay(this.endMonth, null)); - printable.put("endYear", SummaryHelper.formatForDisplay(this.endYear, null)); - printable.put("role", SummaryHelper.formatForDisplay(this.role, null)); - printable.put("startMonth", SummaryHelper.formatForDisplay(this.startMonth, null)); - printable.put("startYear", SummaryHelper.formatForDisplay(this.startYear, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java b/src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java deleted file mode 100644 index c0085c47e..000000000 --- a/src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.mindee.product.resume; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The list of social network profiles of the candidate. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class ResumeV1SocialNetworksUrl extends BaseField implements LineItemField { - - /** - * The name of the social network. - */ - @JsonProperty("name") - String name; - /** - * The URL of the social network. - */ - @JsonProperty("url") - String url; - - public boolean isEmpty() { - return ((name == null || name.isEmpty()) && (url == null || url.isEmpty())); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("name", SummaryHelper.formatForDisplay(this.name, 20)); - printable.put("url", SummaryHelper.formatForDisplay(this.url, 50)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-20s ", printable.get("name")) - + String.format("| %-50s |", printable.get("url")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Name: %s", printable.get("name")) - + String.format(", URL: %s", printable.get("url")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("name", SummaryHelper.formatForDisplay(this.name, null)); - printable.put("url", SummaryHelper.formatForDisplay(this.url, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/us/bankcheck/BankCheckV1.java b/src/main/java/com/mindee/product/us/bankcheck/BankCheckV1.java deleted file mode 100644 index 4874692a7..000000000 --- a/src/main/java/com/mindee/product/us/bankcheck/BankCheckV1.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mindee.product.us.bankcheck; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Bank Check API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "bank_check", version = "1") -public class BankCheckV1 extends Inference { -} diff --git a/src/main/java/com/mindee/product/us/bankcheck/BankCheckV1Document.java b/src/main/java/com/mindee/product/us/bankcheck/BankCheckV1Document.java deleted file mode 100644 index 9aaf119f6..000000000 --- a/src/main/java/com/mindee/product/us/bankcheck/BankCheckV1Document.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.mindee.product.us.bankcheck; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.AmountField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Bank Check API version 1.1 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class BankCheckV1Document extends Prediction { - - /** - * The check payer's account number. - */ - @JsonProperty("account_number") - protected StringField accountNumber; - /** - * The amount of the check. - */ - @JsonProperty("amount") - protected AmountField amount; - /** - * The issuer's check number. - */ - @JsonProperty("check_number") - protected StringField checkNumber; - /** - * The date the check was issued. - */ - @JsonProperty("date") - protected DateField date; - /** - * List of the check's payees (recipients). - */ - @JsonProperty("payees") - protected List payees = new ArrayList<>(); - /** - * The check issuer's routing number. - */ - @JsonProperty("routing_number") - protected StringField routingNumber; - - @Override - public boolean isEmpty() { - return (this.date == null - && this.amount == null - && (this.payees == null || this.payees.isEmpty()) - && this.routingNumber == null - && this.accountNumber == null - && this.checkNumber == null); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Check Issue Date: %s%n", this.getDate())); - outStr.append(String.format(":Amount: %s%n", this.getAmount())); - String payees = SummaryHelper.arrayToString(this.getPayees(), "%n "); - outStr.append(String.format(":Payees: %s%n", payees)); - outStr.append(String.format(":Routing Number: %s%n", this.getRoutingNumber())); - outStr.append(String.format(":Account Number: %s%n", this.getAccountNumber())); - outStr.append(String.format(":Check Number: %s%n", this.getCheckNumber())); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/us/bankcheck/BankCheckV1Page.java b/src/main/java/com/mindee/product/us/bankcheck/BankCheckV1Page.java deleted file mode 100644 index 28c2b991e..000000000 --- a/src/main/java/com/mindee/product/us/bankcheck/BankCheckV1Page.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.mindee.product.us.bankcheck; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.PositionField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Bank Check API version 1.1 page data. - */ -@Getter -@EqualsAndHashCode(callSuper = true) -@JsonIgnoreProperties(ignoreUnknown = true) -public class BankCheckV1Page extends BankCheckV1Document { - - /** - * The position of the check on the document. - */ - @JsonProperty("check_position") - protected PositionField checkPosition; - - /** - * List of signature positions. - */ - @JsonProperty("signatures_positions") - protected List signaturesPositions = new ArrayList<>(); - - @Override - public boolean isEmpty() { - return (this.checkPosition == null - && (this.signaturesPositions == null || this.signaturesPositions.isEmpty())); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Check Position: %s%n", this.getCheckPosition())); - String signaturesPositions = SummaryHelper - .arrayToString(this.getSignaturesPositions(), "%n "); - outStr.append(String.format(":Signature Positions: %s%n", signaturesPositions)); - outStr.append(super.toString()); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1.java b/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1.java deleted file mode 100644 index 2769aac21..000000000 --- a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mindee.product.us.healthcarecard; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Healthcare Card API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "us_healthcare_cards", version = "1") -public class HealthcareCardV1 - extends Inference { -} diff --git a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Copay.java b/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Copay.java deleted file mode 100644 index 4e6e3c10b..000000000 --- a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Copay.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.mindee.product.us.healthcarecard; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * Copayments for covered services. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class HealthcareCardV1Copay extends BaseField implements LineItemField { - - /** - * The price of the service. - */ - @JsonProperty("service_fees") - Double serviceFees; - /** - * The name of the service. - */ - @JsonProperty("service_name") - String serviceName; - - public boolean isEmpty() { - return (serviceFees == null && (serviceName == null || serviceName.isEmpty())); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("serviceFees", SummaryHelper.formatAmount(this.serviceFees)); - printable.put("serviceName", SummaryHelper.formatForDisplay(this.serviceName, 20)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-12s ", printable.get("serviceFees")) - + String.format("| %-20s |", printable.get("serviceName")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Service Fees: %s", printable.get("serviceFees")) - + String.format(", Service Name: %s", printable.get("serviceName")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("serviceFees", SummaryHelper.formatAmount(this.serviceFees)); - printable.put("serviceName", SummaryHelper.formatForDisplay(this.serviceName, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java b/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java deleted file mode 100644 index 008ff16a9..000000000 --- a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.mindee.product.us.healthcarecard; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Healthcare Card API version 1.3 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class HealthcareCardV1Document extends Prediction { - - /** - * The name of the company that provides the healthcare plan. - */ - @JsonProperty("company_name") - protected StringField companyName; - /** - * Copayments for covered services. - */ - @JsonProperty("copays") - protected List copays = new ArrayList<>(); - /** - * The list of dependents covered by the healthcare plan. - */ - @JsonProperty("dependents") - protected List dependents = new ArrayList<>(); - /** - * The date when the member enrolled in the healthcare plan. - */ - @JsonProperty("enrollment_date") - protected DateField enrollmentDate; - /** - * The group number associated with the healthcare plan. - */ - @JsonProperty("group_number") - protected StringField groupNumber; - /** - * The organization that issued the healthcare plan. - */ - @JsonProperty("issuer_80840") - protected StringField issuer80840; - /** - * The unique identifier for the member in the healthcare system. - */ - @JsonProperty("member_id") - protected StringField memberId; - /** - * The name of the member covered by the healthcare plan. - */ - @JsonProperty("member_name") - protected StringField memberName; - /** - * The unique identifier for the payer in the healthcare system. - */ - @JsonProperty("payer_id") - protected StringField payerId; - /** - * The name of the healthcare plan. - */ - @JsonProperty("plan_name") - protected StringField planName; - /** - * The BIN number for prescription drug coverage. - */ - @JsonProperty("rx_bin") - protected StringField rxBin; - /** - * The group number for prescription drug coverage. - */ - @JsonProperty("rx_grp") - protected StringField rxGrp; - /** - * The ID number for prescription drug coverage. - */ - @JsonProperty("rx_id") - protected StringField rxId; - /** - * The PCN number for prescription drug coverage. - */ - @JsonProperty("rx_pcn") - protected StringField rxPcn; - - @Override - public boolean isEmpty() { - return (this.companyName == null - && this.planName == null - && this.memberName == null - && this.memberId == null - && this.issuer80840 == null - && (this.dependents == null || this.dependents.isEmpty()) - && this.groupNumber == null - && this.payerId == null - && this.rxBin == null - && this.rxId == null - && this.rxGrp == null - && this.rxPcn == null - && (this.copays == null || this.copays.isEmpty()) - && this.enrollmentDate == null); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Company Name: %s%n", this.getCompanyName())); - outStr.append(String.format(":Plan Name: %s%n", this.getPlanName())); - outStr.append(String.format(":Member Name: %s%n", this.getMemberName())); - outStr.append(String.format(":Member ID: %s%n", this.getMemberId())); - outStr.append(String.format(":Issuer 80840: %s%n", this.getIssuer80840())); - String dependents = SummaryHelper.arrayToString(this.getDependents(), "%n "); - outStr.append(String.format(":Dependents: %s%n", dependents)); - outStr.append(String.format(":Group Number: %s%n", this.getGroupNumber())); - outStr.append(String.format(":Payer ID: %s%n", this.getPayerId())); - outStr.append(String.format(":RX BIN: %s%n", this.getRxBin())); - outStr.append(String.format(":RX ID: %s%n", this.getRxId())); - outStr.append(String.format(":RX GRP: %s%n", this.getRxGrp())); - outStr.append(String.format(":RX PCN: %s%n", this.getRxPcn())); - String copaysSummary = ""; - if (!this.getCopays().isEmpty()) { - int[] copaysColSizes = new int[] { 14, 22 }; - copaysSummary = String.format("%n%s%n ", SummaryHelper.lineSeparator(copaysColSizes, "-")) - + "| Service Fees " - + "| Service Name " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(copaysColSizes, "=")); - copaysSummary += SummaryHelper.arrayToString(this.getCopays(), copaysColSizes); - copaysSummary += String.format("%n%s", SummaryHelper.lineSeparator(copaysColSizes, "-")); - } - outStr.append(String.format(":Copays: %s%n", copaysSummary)); - outStr.append(String.format(":Enrollment Date: %s%n", this.getEnrollmentDate())); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/us/usmail/UsMailV3.java b/src/main/java/com/mindee/product/us/usmail/UsMailV3.java deleted file mode 100644 index f84039435..000000000 --- a/src/main/java/com/mindee/product/us/usmail/UsMailV3.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mindee.product.us.usmail; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * US Mail API version 3 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "us_mail", version = "3") -public class UsMailV3 extends Inference { -} diff --git a/src/main/java/com/mindee/product/us/usmail/UsMailV3Document.java b/src/main/java/com/mindee/product/us/usmail/UsMailV3Document.java deleted file mode 100644 index c3f617cfb..000000000 --- a/src/main/java/com/mindee/product/us/usmail/UsMailV3Document.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.mindee.product.us.usmail; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.BooleanField; -import com.mindee.parsing.standard.StringField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * US Mail API version 3.0 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class UsMailV3Document extends Prediction { - - /** - * Whether the mailing is marked as return to sender. - */ - @JsonProperty("is_return_to_sender") - protected BooleanField isReturnToSender; - /** - * The addresses of the recipients. - */ - @JsonProperty("recipient_addresses") - protected List recipientAddresses = new ArrayList<>(); - /** - * The names of the recipients. - */ - @JsonProperty("recipient_names") - protected List recipientNames = new ArrayList<>(); - /** - * The address of the sender. - */ - @JsonProperty("sender_address") - protected UsMailV3SenderAddress senderAddress; - /** - * The name of the sender. - */ - @JsonProperty("sender_name") - protected StringField senderName; - - @Override - public boolean isEmpty() { - return (this.senderName == null - && this.senderAddress == null - && (this.recipientNames == null || this.recipientNames.isEmpty()) - && (this.recipientAddresses == null || this.recipientAddresses.isEmpty()) - && this.isReturnToSender == null); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append(String.format(":Sender Name: %s%n", this.getSenderName())); - outStr.append(String.format(":Sender Address:%n%s", this.getSenderAddress().toFieldList())); - String recipientNames = SummaryHelper - .arrayToString(this.getRecipientNames(), "%n "); - outStr.append(String.format(":Recipient Names: %s%n", recipientNames)); - String recipientAddressesSummary = ""; - if (!this.getRecipientAddresses().isEmpty()) { - int[] recipientAddressesColSizes = new int[] { 17, 37, 19, 13, 24, 7, 27, 17 }; - recipientAddressesSummary = String - .format("%n%s%n ", SummaryHelper.lineSeparator(recipientAddressesColSizes, "-")) - + "| City " - + "| Complete Address " - + "| Is Address Change " - + "| Postal Code " - + "| Private Mailbox Number " - + "| State " - + "| Street " - + "| Unit " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(recipientAddressesColSizes, "=")); - recipientAddressesSummary += SummaryHelper - .arrayToString(this.getRecipientAddresses(), recipientAddressesColSizes); - recipientAddressesSummary += String - .format("%n%s", SummaryHelper.lineSeparator(recipientAddressesColSizes, "-")); - } - outStr.append(String.format(":Recipient Addresses: %s%n", recipientAddressesSummary)); - outStr.append(String.format(":Return to Sender: %s%n", this.getIsReturnToSender())); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/us/usmail/UsMailV3RecipientAddress.java b/src/main/java/com/mindee/product/us/usmail/UsMailV3RecipientAddress.java deleted file mode 100644 index 008d51d81..000000000 --- a/src/main/java/com/mindee/product/us/usmail/UsMailV3RecipientAddress.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.mindee.product.us.usmail; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The addresses of the recipients. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class UsMailV3RecipientAddress extends BaseField implements LineItemField { - - /** - * The city of the recipient's address. - */ - @JsonProperty("city") - String city; - /** - * The complete address of the recipient. - */ - @JsonProperty("complete") - String complete; - /** - * Indicates if the recipient's address is a change of address. - */ - @JsonProperty("is_address_change") - Boolean isAddressChange; - /** - * The postal code of the recipient's address. - */ - @JsonProperty("postal_code") - String postalCode; - /** - * The private mailbox number of the recipient's address. - */ - @JsonProperty("private_mailbox_number") - String privateMailboxNumber; - /** - * Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. - */ - @JsonProperty("state") - String state; - /** - * The street of the recipient's address. - */ - @JsonProperty("street") - String street; - /** - * The unit number of the recipient's address. - */ - @JsonProperty("unit") - String unit; - - public boolean isEmpty() { - return ((city == null || city.isEmpty()) - && (complete == null || complete.isEmpty()) - && isAddressChange == null - && (postalCode == null || postalCode.isEmpty()) - && (privateMailboxNumber == null || privateMailboxNumber.isEmpty()) - && (state == null || state.isEmpty()) - && (street == null || street.isEmpty()) - && (unit == null || unit.isEmpty())); - } - - private Map tablePrintableValues() { - Map printable = new HashMap<>(); - - printable.put("city", SummaryHelper.formatForDisplay(this.city, 15)); - printable.put("complete", SummaryHelper.formatForDisplay(this.complete, 35)); - printable.put("isAddressChange", SummaryHelper.formatForDisplay(this.isAddressChange, null)); - printable.put("postalCode", SummaryHelper.formatForDisplay(this.postalCode, null)); - printable - .put("privateMailboxNumber", SummaryHelper.formatForDisplay(this.privateMailboxNumber, null)); - printable.put("state", SummaryHelper.formatForDisplay(this.state, null)); - printable.put("street", SummaryHelper.formatForDisplay(this.street, 25)); - printable.put("unit", SummaryHelper.formatForDisplay(this.unit, 15)); - return printable; - } - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.tablePrintableValues(); - return String.format("| %-15s ", printable.get("city")) - + String.format("| %-35s ", printable.get("complete")) - + String.format("| %-17s ", printable.get("isAddressChange")) - + String.format("| %-11s ", printable.get("postalCode")) - + String.format("| %-22s ", printable.get("privateMailboxNumber")) - + String.format("| %-5s ", printable.get("state")) - + String.format("| %-25s ", printable.get("street")) - + String.format("| %-15s |", printable.get("unit")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("City: %s", printable.get("city")) - + String.format(", Complete Address: %s", printable.get("complete")) - + String.format(", Is Address Change: %s", printable.get("isAddressChange")) - + String.format(", Postal Code: %s", printable.get("postalCode")) - + String.format(", Private Mailbox Number: %s", printable.get("privateMailboxNumber")) - + String.format(", State: %s", printable.get("state")) - + String.format(", Street: %s", printable.get("street")) - + String.format(", Unit: %s", printable.get("unit")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("city", SummaryHelper.formatForDisplay(this.city, null)); - printable.put("complete", SummaryHelper.formatForDisplay(this.complete, null)); - printable.put("isAddressChange", SummaryHelper.formatForDisplay(this.isAddressChange, null)); - printable.put("postalCode", SummaryHelper.formatForDisplay(this.postalCode, null)); - printable - .put("privateMailboxNumber", SummaryHelper.formatForDisplay(this.privateMailboxNumber, null)); - printable.put("state", SummaryHelper.formatForDisplay(this.state, null)); - printable.put("street", SummaryHelper.formatForDisplay(this.street, null)); - printable.put("unit", SummaryHelper.formatForDisplay(this.unit, null)); - return printable; - } -} diff --git a/src/main/java/com/mindee/product/us/usmail/UsMailV3SenderAddress.java b/src/main/java/com/mindee/product/us/usmail/UsMailV3SenderAddress.java deleted file mode 100644 index 45f89ca48..000000000 --- a/src/main/java/com/mindee/product/us/usmail/UsMailV3SenderAddress.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.mindee.product.us.usmail; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -/** - * The address of the sender. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class UsMailV3SenderAddress extends BaseField { - - /** - * The city of the sender's address. - */ - @JsonProperty("city") - String city; - /** - * The complete address of the sender. - */ - @JsonProperty("complete") - String complete; - /** - * The postal code of the sender's address. - */ - @JsonProperty("postal_code") - String postalCode; - /** - * Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. - */ - @JsonProperty("state") - String state; - /** - * The street of the sender's address. - */ - @JsonProperty("street") - String street; - - public boolean isEmpty() { - return ((city == null || city.isEmpty()) - && (complete == null || complete.isEmpty()) - && (postalCode == null || postalCode.isEmpty()) - && (state == null || state.isEmpty()) - && (street == null || street.isEmpty())); - } - - /** - * Output the object in a format suitable for inclusion in an rST field list. - */ - public String toFieldList() { - Map printable = this.printableValues(); - return String.format(" :City: %s%n", printable.get("city")) - + String.format(" :Complete Address: %s%n", printable.get("complete")) - + String.format(" :Postal Code: %s%n", printable.get("postalCode")) - + String.format(" :State: %s%n", printable.get("state")) - + String.format(" :Street: %s%n", printable.get("street")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("City: %s", printable.get("city")) - + String.format(", Complete Address: %s", printable.get("complete")) - + String.format(", Postal Code: %s", printable.get("postalCode")) - + String.format(", State: %s", printable.get("state")) - + String.format(", Street: %s", printable.get("street")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("city", SummaryHelper.formatForDisplay(this.city, null)); - printable.put("complete", SummaryHelper.formatForDisplay(this.complete, null)); - printable.put("postalCode", SummaryHelper.formatForDisplay(this.postalCode, null)); - printable.put("state", SummaryHelper.formatForDisplay(this.state, null)); - printable.put("street", SummaryHelper.formatForDisplay(this.street, null)); - return printable; - } -} diff --git a/src/test/java/com/mindee/MindeeClientTest.java b/src/test/java/com/mindee/MindeeClientTest.java index 4264532c1..7ec009b5c 100644 --- a/src/test/java/com/mindee/MindeeClientTest.java +++ b/src/test/java/com/mindee/MindeeClientTest.java @@ -17,7 +17,6 @@ import com.mindee.parsing.common.PredictResponse; import com.mindee.pdf.PdfOperation; import com.mindee.pdf.SplitPdf; -import com.mindee.product.custom.CustomV1; import com.mindee.product.generated.GeneratedV1; import com.mindee.product.internationalid.InternationalIdV2; import com.mindee.product.invoice.InvoiceV4; @@ -50,56 +49,6 @@ public void setUp() { client = new MindeeClient(pdfOperation, mindeeApi); } - @Test - void givenAClientForCustom_withFile_parse_thenShouldCallMindeeApi() throws IOException { - - PredictResponse predictResponse = new PredictResponse(); - predictResponse.setDocument(new Document<>()); - predictResponse.setApiRequest(null); - Mockito - .when(mindeeApi.predictPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - - PredictResponse document = client - .parse( - new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf")), - new Endpoint("", "", "") - ); - - Assertions.assertNotNull(document); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictPost(Mockito.any(), Mockito.any(), Mockito.any()); - } - - @Test - void givenAClientForCustomAndPageOptions_parse_thenShouldOperateCutOnPagesAndCallTheHttpClientCorrectly() throws IOException { - - List pageNumberToKeep = new ArrayList<>(); - pageNumberToKeep.add(1); - - PredictResponse predictResponse = new PredictResponse(); - predictResponse.setDocument(new Document<>()); - predictResponse.setApiRequest(null); - Mockito - .when(mindeeApi.predictPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - Mockito.when(pdfOperation.split(Mockito.any())).thenReturn(new SplitPdf(new byte[0], 0)); - - PredictResponse document = client - .parse( - new LocalInputSource(getResourcePath("file_types/pdf/multipage.pdf")), - new Endpoint("", "", ""), - new PageOptions(pageNumberToKeep, PageOptionsOperation.KEEP_ONLY, 0) - ); - - Assertions.assertNotNull(document); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictPost(Mockito.any(), Mockito.any(), Mockito.any()); - Mockito.verify(pdfOperation, Mockito.times(1)).split(Mockito.any()); - } - @Test void givenAClientForInvoice_withFile_parse_thenShouldCallMindeeApi() throws IOException { @@ -223,38 +172,6 @@ void givenADocumentUrl_whenParsed_shouldCallApiWithCorrectParams() throws IOExce Assertions.assertNull(requestParametersArgumentCaptor.getValue().getFileName()); } - @Test - void givenACustomDocumentUrl_whenParsed_shouldCallApiWithCorrectParams() throws IOException { - - ArgumentCaptor classArgumentCaptor = ArgumentCaptor.forClass(Class.class); - ArgumentCaptor endpointArgumentCaptor = ArgumentCaptor.forClass(Endpoint.class); - ArgumentCaptor requestParametersArgumentCaptor = ArgumentCaptor - .forClass(RequestParameters.class); - - URL docUrl = new URL("https://this.document.does.not.exist"); - Endpoint endpoint = new Endpoint("dsddw", "dcsdcd", "dsfdd"); - PredictResponse predictResponse = new PredictResponse(); - predictResponse.setDocument(new Document<>()); - predictResponse.setApiRequest(null); - Mockito - .when(mindeeApi.predictPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - PredictResponse document = client.parse(docUrl, endpoint); - - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictPost( - classArgumentCaptor.capture(), - endpointArgumentCaptor.capture(), - requestParametersArgumentCaptor.capture() - ); - Assertions.assertEquals(CustomV1.class, classArgumentCaptor.getValue()); - Assertions.assertEquals(docUrl, requestParametersArgumentCaptor.getValue().getFileUrl()); - Assertions.assertEquals(endpoint, endpointArgumentCaptor.getValue()); - Assertions.assertNull(requestParametersArgumentCaptor.getValue().getFile()); - Assertions.assertNull(requestParametersArgumentCaptor.getValue().getFileName()); - } - @Test void givenAnAsyncDoc_whenEnqueued_shouldInvokeApiCorrectly() throws IOException { diff --git a/src/test/java/com/mindee/parsing/custom/lineitems/FakeListField.java b/src/test/java/com/mindee/parsing/custom/lineitems/FakeListField.java deleted file mode 100644 index 4113c3be2..000000000 --- a/src/test/java/com/mindee/parsing/custom/lineitems/FakeListField.java +++ /dev/null @@ -1,589 +0,0 @@ -package com.mindee.parsing.custom.lineitems; - -import com.mindee.geometry.Point; -import com.mindee.geometry.Polygon; -import com.mindee.parsing.custom.ListField; -import com.mindee.parsing.custom.ListFieldValue; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -class FakeListField { - private FakeListField() { - } - - static Map get2completeLines1halfLine() { - Map fakes = new HashMap<>(); - fakes - .put( - "birthDates", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "1986-10-23", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.818, 0.398), - new Point(0.902, 0.398), - new Point(0.902, 0.406), - new Point(0.818, 0.406) - ) - ) - ), - new ListFieldValue( - "2012-02-13", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.819, 0.442), - new Point(0.902, 0.442), - new Point(0.902, 0.451), - new Point(0.819, 0.451) - ) - ) - ), - new ListFieldValue( - "1895-02-28", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.819, 0.462), - new Point(0.902, 0.462), - new Point(0.902, 0.471), - new Point(0.819, 0.471) - ) - ) - ) - ) - ) - ); - fakes - .put( - "names", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "Kevin", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.082, 0.398), - new Point(0.144, 0.398), - new Point(0.144, 0.407), - new Point(0.082, 0.407) - ) - ) - ), - new ListFieldValue( - "Mindee", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.152, 0.398), - new Point(0.222, 0.398), - new Point(0.222, 0.407), - new Point(0.152, 0.407) - ) - ) - ), - new ListFieldValue( - "Ianaré", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.081, 0.442), - new Point(0.15, 0.442), - new Point(0.15, 0.451), - new Point(0.081, 0.451) - ) - ) - ), - new ListFieldValue( - "Mindee", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.157, 0.442), - new Point(0.26, 0.442), - new Point(0.26, 0.451), - new Point(0.157, 0.451) - ) - ) - ) - ) - ) - ); - - return fakes; - } - - static Map getWith2ValuesByExpectedLines() { - Map fakes = new HashMap<>(); - fakes - .put( - "birthDates", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "1986-10-23", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.818, 0.398), - new Point(0.902, 0.398), - new Point(0.902, 0.406), - new Point(0.818, 0.406) - ) - ) - ), - new ListFieldValue( - "2012-02-13", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.819, 0.442), - new Point(0.902, 0.442), - new Point(0.902, 0.451), - new Point(0.819, 0.451) - ) - ) - ) - ) - ) - ); - - fakes - .put( - "names", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "Kevin", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.082, 0.398), - new Point(0.144, 0.398), - new Point(0.144, 0.407), - new Point(0.082, 0.407) - ) - ) - ), - new ListFieldValue( - "Mindee", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.152, 0.398), - new Point(0.222, 0.398), - new Point(0.222, 0.407), - new Point(0.152, 0.407) - ) - ) - ), - new ListFieldValue( - "Ianaré", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.081, 0.442), - new Point(0.15, 0.442), - new Point(0.15, 0.451), - new Point(0.081, 0.451) - ) - ) - ), - new ListFieldValue( - "Mindee", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.157, 0.442), - new Point(0.26, 0.442), - new Point(0.26, 0.451), - new Point(0.157, 0.451) - ) - ) - ) - ) - ) - ); - - return fakes; - } - - static Map getWith1FieldValueForTheLastLine() { - Map fakes = new HashMap<>(); - - fakes - .put( - "birthDates", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "1986-10-23", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.818, 0.398), - new Point(0.902, 0.398), - new Point(0.902, 0.406), - new Point(0.818, 0.406) - ) - ) - ), - new ListFieldValue( - "2012-02-13", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.819, 0.442), - new Point(0.902, 0.442), - new Point(0.902, 0.451), - new Point(0.819, 0.451) - ) - ) - ) - ) - ) - ); - - fakes - .put( - "names", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "Kevin", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.082, 0.398), - new Point(0.144, 0.398), - new Point(0.144, 0.407), - new Point(0.082, 0.407) - ) - ) - ), - new ListFieldValue( - "Mindee", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.152, 0.398), - new Point(0.222, 0.398), - new Point(0.222, 0.407), - new Point(0.152, 0.407) - ) - ) - ), - new ListFieldValue( - "Ianaré", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.081, 0.442), - new Point(0.15, 0.442), - new Point(0.15, 0.451), - new Point(0.081, 0.451) - ) - ) - ), - new ListFieldValue( - "Mindee", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.157, 0.442), - new Point(0.26, 0.442), - new Point(0.26, 0.451), - new Point(0.157, 0.451) - ) - ) - ), - new ListFieldValue( - "Bob", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.082, 0.486), - new Point(0.151, 0.486), - new Point(0.151, 0.495), - new Point(0.082, 0.495) - ) - ) - ) - ) - ) - ); - - return fakes; - } - - static Map getWith1ExpectedLines() { - Map fakes = new HashMap<>(); - fakes - .put( - "birthDates", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "1986-10-23", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.818, 0.398), - new Point(0.902, 0.398), - new Point(0.902, 0.406), - new Point(0.818, 0.406) - ) - ) - ) - ) - ) - ); - fakes - .put( - "names", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "Kevin", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.082, 0.398), - new Point(0.144, 0.398), - new Point(0.144, 0.407), - new Point(0.082, 0.407) - ) - ) - ), - new ListFieldValue( - "Mindee", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.152, 0.398), - new Point(0.222, 0.398), - new Point(0.222, 0.407), - new Point(0.152, 0.407) - ) - ) - ) - ) - ) - ); - return fakes; - } - - static Map getWithPolygonsNotExactlyOnTheSameAxis() { - Map fakes = new HashMap<>(); - fakes - .put( - "birthDates", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "1986-10-23", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.576, 0.401), - new Point(0.649, 0.401), - new Point(0.649, 0.408), - new Point(0.576, 0.408) - ) - ) - ), - new ListFieldValue( - "2012-02-13", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.581, 0.45), - new Point(0.656, 0.45), - new Point(0.656, 0.458), - new Point(0.581, 0.458) - ) - ) - ) - ) - ) - ); - fakes - .put( - "names", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "Kevin", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.119, 0.4), - new Point(0.179, 0.4), - new Point(0.178, 0.41), - new Point(0.119, 0.409) - ) - ) - ), - new ListFieldValue( - "Mindee", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.185, 0.401), - new Point(0.232, 0.401), - new Point(0.232, 0.41), - new Point(0.184, 0.409) - ) - ) - ), - new ListFieldValue( - "Ianaré", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.118, 0.45), - new Point(0.169, 0.451), - new Point(0.169, 0.458), - new Point(0.117, 0.457) - ) - ) - ) - ) - ) - ); - return fakes; - } - - static Map getSampleWichRender2LinesInsteadOfOne() { - Map fakes = new HashMap<>(); - fakes - .put( - "names", - new ListField( - 1.0, - Arrays - .asList( - new ListFieldValue( - "A", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.075, 0.42), - new Point(0.141, 0.42), - new Point(0.141, 0.428), - new Point(0.075, 0.428) - ) - ) - ), - new ListFieldValue( - "B", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.148, 0.42), - new Point(0.198, 0.42), - new Point(0.198, 0.428), - new Point(0.148, 0.428) - ) - ) - ), - new ListFieldValue( - "C", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.2, 0.42), - new Point(0.204, 0.42), - new Point(0.204, 0.428), - new Point(0.2, 0.428) - ) - ) - ), - new ListFieldValue( - "D", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.206, 0.42), - new Point(0.257, 0.42), - new Point(0.257, 0.428), - new Point(0.206, 0.428) - ) - ) - ), - new ListFieldValue( - "E", - 1.0, - new Polygon( - Arrays - .asList( - new Point(0.263, 0.42), - new Point(0.33, 0.42), - new Point(0.33, 0.428), - new Point(0.263, 0.428) - ) - ) - ) - ) - ) - ); - return fakes; - } -} diff --git a/src/test/java/com/mindee/parsing/custom/lineitems/LineGeneratorTest.java b/src/test/java/com/mindee/parsing/custom/lineitems/LineGeneratorTest.java deleted file mode 100644 index 346b0bf68..000000000 --- a/src/test/java/com/mindee/parsing/custom/lineitems/LineGeneratorTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.mindee.parsing.custom.lineitems; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import org.apache.commons.math3.util.Precision; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class LineGeneratorTest { - - private static final List anchors = Collections.singletonList(new Anchor("names", 0.01d)); - - @Test - void prepareLinesWith2ValuesOnEachLineWithPolygonValuesOnExactlyTheSameAxis() { - Collection lines = LineGenerator - .prepareLines(FakeListField.getWith2ValuesByExpectedLines(), anchors) - .getLines(); - Assertions.assertEquals(2, lines.size()); - } - - @Test - void prepareLinesWhenAnchorHasMoreLines() { - Collection lines = LineGenerator - .prepareLines( - FakeListField.get2completeLines1halfLine(), - Collections.singletonList(new Anchor("birthDates")) - ) - .getLines(); - Assertions.assertEquals(3, lines.size()); - } - - @Test - void prepareLinesWithTwoAnchors() { - PreparedLines preparedLines = LineGenerator - .prepareLines( - FakeListField.get2completeLines1halfLine(), - Arrays.asList(new Anchor("names"), new Anchor("birthDates")) - ); - Assertions.assertEquals("birthDates", preparedLines.getAnchor().getName()); - Assertions.assertEquals(3, preparedLines.getLines().size()); - } - - @Test - void prepareLinesWith1FieldValueForTheLastLine() { - Collection lines = LineGenerator - .prepareLines(FakeListField.getWith1FieldValueForTheLastLine(), anchors) - .getLines(); - Assertions.assertEquals(3, lines.size()); - } - - @Test - void prepareLinesWith1ExpectedLine() { - Collection table = LineGenerator - .prepareLines(FakeListField.getWith1ExpectedLines(), anchors) - .getLines(); - Assertions.assertEquals(1, table.size()); - } - - @Test - void prepareLinesWithPolygonsNotExactlyOnTheSameAxis() { - List anchors = Collections.singletonList(new Anchor("names", 0.005d)); - Collection table = LineGenerator - .prepareLines(FakeListField.getWithPolygonsNotExactlyOnTheSameAxis(), anchors) - .getLines(); - Assertions.assertEquals(2, table.size()); - } - - @Test - void prepareLinesWhichRender2LinesInsteadOfOne() { - List anchors = Collections.singletonList(new Anchor("names", 0.0d)); - Collection table = LineGenerator - .prepareLines(FakeListField.getSampleWichRender2LinesInsteadOfOne(), anchors) - .getLines(); - Assertions.assertEquals(1, table.size()); - } - - @Test - void test() { - Assertions.assertTrue(Precision.equals(0.410, 0.420, 0.011d)); - } - -} diff --git a/src/test/java/com/mindee/product/billoflading/BillOfLadingV1Test.java b/src/test/java/com/mindee/product/billoflading/BillOfLadingV1Test.java deleted file mode 100644 index 4e1673e8f..000000000 --- a/src/test/java/com/mindee/product/billoflading/BillOfLadingV1Test.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.mindee.product.billoflading; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for BillOfLadingV1. - */ -public class BillOfLadingV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, BillOfLadingV1.class); - return objectMapper - .readValue( - new File(getV1ResourcePathString("products/bill_of_lading/response_v1/" + name + ".json")), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - BillOfLadingV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getBillOfLadingNumber().getValue()); - Assertions.assertNull(docPrediction.getShipper().getAddress()); - Assertions.assertNull(docPrediction.getShipper().getEmail()); - Assertions.assertNull(docPrediction.getShipper().getName()); - Assertions.assertNull(docPrediction.getShipper().getPhone()); - Assertions.assertNull(docPrediction.getConsignee().getAddress()); - Assertions.assertNull(docPrediction.getConsignee().getEmail()); - Assertions.assertNull(docPrediction.getConsignee().getName()); - Assertions.assertNull(docPrediction.getConsignee().getPhone()); - Assertions.assertNull(docPrediction.getNotifyParty().getAddress()); - Assertions.assertNull(docPrediction.getNotifyParty().getEmail()); - Assertions.assertNull(docPrediction.getNotifyParty().getName()); - Assertions.assertNull(docPrediction.getNotifyParty().getPhone()); - Assertions.assertNull(docPrediction.getCarrier().getName()); - Assertions.assertNull(docPrediction.getCarrier().getProfessionalNumber()); - Assertions.assertNull(docPrediction.getCarrier().getScac()); - Assertions.assertTrue(docPrediction.getCarrierItems().isEmpty()); - Assertions.assertNull(docPrediction.getPortOfLoading().getValue()); - Assertions.assertNull(docPrediction.getPortOfDischarge().getValue()); - Assertions.assertNull(docPrediction.getPlaceOfDelivery().getValue()); - Assertions.assertNull(docPrediction.getDateOfIssue().getValue()); - Assertions.assertNull(docPrediction.getDepartureDate().getValue()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/bill_of_lading/response_v1/summary_full.rst") - ); - } - -} diff --git a/src/test/java/com/mindee/product/businesscard/BusinessCardV1Test.java b/src/test/java/com/mindee/product/businesscard/BusinessCardV1Test.java deleted file mode 100644 index 0bfe0e100..000000000 --- a/src/test/java/com/mindee/product/businesscard/BusinessCardV1Test.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.mindee.product.businesscard; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for BusinessCardV1. - */ -public class BusinessCardV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, BusinessCardV1.class); - return objectMapper - .readValue( - new File(getV1ResourcePathString("products/business_card/response_v1/" + name + ".json")), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - BusinessCardV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getFirstname().getValue()); - Assertions.assertNull(docPrediction.getLastname().getValue()); - Assertions.assertNull(docPrediction.getJobTitle().getValue()); - Assertions.assertNull(docPrediction.getCompany().getValue()); - Assertions.assertNull(docPrediction.getEmail().getValue()); - Assertions.assertNull(docPrediction.getPhoneNumber().getValue()); - Assertions.assertNull(docPrediction.getMobileNumber().getValue()); - Assertions.assertNull(docPrediction.getFaxNumber().getValue()); - Assertions.assertNull(docPrediction.getAddress().getValue()); - Assertions.assertNull(docPrediction.getWebsite().getValue()); - Assertions.assertTrue(docPrediction.getSocialMedia().isEmpty()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/business_card/response_v1/summary_full.rst") - ); - } - -} diff --git a/src/test/java/com/mindee/product/custom/CustomV1Test.java b/src/test/java/com/mindee/product/custom/CustomV1Test.java deleted file mode 100644 index 88d08ecff..000000000 --- a/src/test/java/com/mindee/product/custom/CustomV1Test.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.mindee.product.custom; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.Page; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.custom.ListField; -import com.mindee.parsing.custom.ListFieldValue; -import java.io.File; -import java.io.IOException; -import java.util.Map; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class CustomV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, CustomV1.class); - return objectMapper - .readValue( - new File(getV1ResourcePathString("products/custom/response_v1/" + name + ".json")), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - CustomV1Document docPrediction = response.getDocument().getInference().getPrediction(); - - Assertions.assertFalse(docPrediction.getFields().isEmpty()); - for (Map.Entry entry : docPrediction.getFields().entrySet()) { - ListField field = entry.getValue(); - Assertions.assertTrue(field.getValues().isEmpty()); - } - Assertions.assertFalse(docPrediction.getClassificationFields().isEmpty()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidPageId() throws IOException { - PredictResponse response = getPrediction("complete"); - CustomV1 inference = response.getDocument().getInference(); - CustomV1Document docPrediction = inference.getPrediction(); - for (Map.Entry entry : docPrediction.getFields().entrySet()) { - ListField field = entry.getValue(); - Assertions.assertFalse(field.isEmpty()); - Assertions.assertNotNull(field.getContentsList()); - for (ListFieldValue value : field.getValues()) { - Assertions.assertNotNull(value.getContent()); - Assertions.assertNotNull(value.getPageId()); - } - } - Page page = inference.getPages().get(0); - Assertions.assertEquals(0, page.getPageId()); - - CustomV1Page pagePrediction = page.getPrediction(); - Assertions.assertEquals(10, pagePrediction.size()); - for (Map.Entry entry : pagePrediction.entrySet()) { - ListField field = entry.getValue(); - for (ListFieldValue value : field.getValues()) { - Assertions.assertNotNull(value.getContent()); - } - } - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/custom/response_v1/summary_full.rst") - ); - } - - @Test - void whenCompleteDeserialized_mustHaveValidPage0Summary() throws IOException { - PredictResponse response = getPrediction("complete"); - Page page = response.getDocument().getInference().getPages().get(0); - assertStringEqualsFile( - page.toString(), - getV1ResourcePathString("products/custom/response_v1/summary_page0.rst") - ); - } -} diff --git a/src/test/java/com/mindee/product/custom/CustomV1WithLineItemsTest.java b/src/test/java/com/mindee/product/custom/CustomV1WithLineItemsTest.java deleted file mode 100644 index b404e2e25..000000000 --- a/src/test/java/com/mindee/product/custom/CustomV1WithLineItemsTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.mindee.product.custom; - -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.custom.lineitems.Anchor; -import com.mindee.parsing.custom.lineitems.Line; -import com.mindee.parsing.custom.lineitems.LineItems; -import com.mindee.parsing.custom.lineitems.LineItemsGenerator; -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class CustomV1WithLineItemsTest { - - @Test - void givenACustomDocument_expected_3_lines() throws IOException { - - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, CustomV1.class); - PredictResponse response = objectMapper - .readValue( - new File( - getV1ResourcePathString("products/custom/response_v1/line_items/single_table_01.json") - ), - type - ); - - LineItems lineItems = LineItemsGenerator - .generate( - Arrays - .asList( - "beneficiary_birth_date", - "beneficiary_number", - "beneficiary_name", - "beneficiary_rank" - ), - response.getDocument().getInference().getPrediction().getFields(), - new Anchor("beneficiary_name", 0.011d) - ); - - Assertions.assertNotNull(lineItems); - Assertions.assertEquals(3, lineItems.getRows().size()); - Line line1 = lineItems.getRows().get(0); - Assertions.assertEquals(0.059, line1.getBbox().getMinX()); - Assertions.assertEquals(0.351, line1.getBbox().getMinY()); - Assertions.assertEquals(0.3, line1.getBbox().getMaxX()); - Assertions.assertEquals(0.36, line1.getBbox().getMaxY()); - Assertions.assertEquals(4, line1.getFields().size()); - Assertions.assertTrue(line1.getFields().containsKey("beneficiary_birth_date")); - Assertions.assertTrue(line1.getFields().containsKey("beneficiary_number")); - Assertions.assertTrue(line1.getFields().containsKey("beneficiary_name")); - Assertions.assertTrue(line1.getFields().containsKey("beneficiary_rank")); - Assertions - .assertEquals("1970-11-11", line1.getFields().get("beneficiary_birth_date").getValue()); - Assertions.assertEquals("1", line1.getFields().get("beneficiary_rank").getValue()); - Line line2 = lineItems.getRows().get(1); - Assertions - .assertEquals("2010-07-18", line2.getFields().get("beneficiary_birth_date").getValue()); - Assertions.assertEquals("2", line2.getFields().get("beneficiary_rank").getValue()); - Line line3 = lineItems.getRows().get(2); - Assertions - .assertEquals("2015-07-05", line3.getFields().get("beneficiary_birth_date").getValue()); - Assertions.assertEquals("3", line3.getFields().get("beneficiary_rank").getValue()); - } -} diff --git a/src/test/java/com/mindee/product/deliverynote/DeliveryNoteV1Test.java b/src/test/java/com/mindee/product/deliverynote/DeliveryNoteV1Test.java deleted file mode 100644 index 573ce2f7b..000000000 --- a/src/test/java/com/mindee/product/deliverynote/DeliveryNoteV1Test.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.mindee.product.deliverynote; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for DeliveryNoteV1. - */ -public class DeliveryNoteV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, DeliveryNoteV1.class); - return objectMapper - .readValue( - new File(getV1ResourcePathString("products/delivery_notes/response_v1/" + name + ".json")), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - DeliveryNoteV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getDeliveryDate().getValue()); - Assertions.assertNull(docPrediction.getDeliveryNumber().getValue()); - Assertions.assertNull(docPrediction.getSupplierName().getValue()); - Assertions.assertNull(docPrediction.getSupplierAddress().getValue()); - Assertions.assertNull(docPrediction.getCustomerName().getValue()); - Assertions.assertNull(docPrediction.getCustomerAddress().getValue()); - Assertions.assertNull(docPrediction.getTotalAmount().getValue()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/delivery_notes/response_v1/summary_full.rst") - ); - } - -} diff --git a/src/test/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1Test.java b/src/test/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1Test.java deleted file mode 100644 index 7423551b8..000000000 --- a/src/test/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV1Test.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.mindee.product.fr.bankaccountdetails; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for BankAccountDetailsV1. - */ -public class BankAccountDetailsV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, BankAccountDetailsV1.class); - return objectMapper - .readValue( - new File( - getV1ResourcePathString("products/bank_account_details/response_v1/" + name + ".json") - ), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - BankAccountDetailsV1Document docPrediction = response - .getDocument() - .getInference() - .getPrediction(); - Assertions.assertNull(docPrediction.getIban().getValue()); - Assertions.assertNull(docPrediction.getAccountHolderName().getValue()); - Assertions.assertNull(docPrediction.getSwift().getValue()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/bank_account_details/response_v1/summary_full.rst") - ); - } - -} diff --git a/src/test/java/com/mindee/product/fr/energybill/EnergyBillV1Test.java b/src/test/java/com/mindee/product/fr/energybill/EnergyBillV1Test.java deleted file mode 100644 index 5b3a7b6a8..000000000 --- a/src/test/java/com/mindee/product/fr/energybill/EnergyBillV1Test.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.mindee.product.fr.energybill; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for EnergyBillV1. - */ -public class EnergyBillV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, EnergyBillV1.class); - return objectMapper - .readValue( - new File(getV1ResourcePathString("products/energy_bill_fra/response_v1/" + name + ".json")), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - EnergyBillV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getInvoiceNumber().getValue()); - Assertions.assertNull(docPrediction.getContractId().getValue()); - Assertions.assertNull(docPrediction.getDeliveryPoint().getValue()); - Assertions.assertNull(docPrediction.getInvoiceDate().getValue()); - Assertions.assertNull(docPrediction.getDueDate().getValue()); - Assertions.assertNull(docPrediction.getTotalBeforeTaxes().getValue()); - Assertions.assertNull(docPrediction.getTotalTaxes().getValue()); - Assertions.assertNull(docPrediction.getTotalAmount().getValue()); - Assertions.assertNull(docPrediction.getEnergySupplier().getAddress()); - Assertions.assertNull(docPrediction.getEnergySupplier().getName()); - Assertions.assertNull(docPrediction.getEnergyConsumer().getAddress()); - Assertions.assertNull(docPrediction.getEnergyConsumer().getName()); - Assertions.assertTrue(docPrediction.getSubscription().isEmpty()); - Assertions.assertTrue(docPrediction.getEnergyUsage().isEmpty()); - Assertions.assertTrue(docPrediction.getTaxesAndContributions().isEmpty()); - Assertions.assertNull(docPrediction.getMeterDetails().getMeterNumber()); - Assertions.assertNull(docPrediction.getMeterDetails().getMeterType()); - Assertions.assertNull(docPrediction.getMeterDetails().getUnit()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/energy_bill_fra/response_v1/summary_full.rst") - ); - } - -} diff --git a/src/test/java/com/mindee/product/fr/healthcard/HealthCardV1Test.java b/src/test/java/com/mindee/product/fr/healthcard/HealthCardV1Test.java deleted file mode 100644 index 69e467478..000000000 --- a/src/test/java/com/mindee/product/fr/healthcard/HealthCardV1Test.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.mindee.product.fr.healthcard; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for HealthCardV1. - */ -public class HealthCardV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, HealthCardV1.class); - return objectMapper - .readValue( - new File( - getV1ResourcePathString("products/french_healthcard/response_v1/" + name + ".json") - ), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - HealthCardV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertTrue(docPrediction.getGivenNames().isEmpty()); - Assertions.assertNull(docPrediction.getSurname().getValue()); - Assertions.assertNull(docPrediction.getSocialSecurity().getValue()); - Assertions.assertNull(docPrediction.getIssuanceDate().getValue()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/french_healthcard/response_v1/summary_full.rst") - ); - } - -} diff --git a/src/test/java/com/mindee/product/fr/payslip/PayslipV3Test.java b/src/test/java/com/mindee/product/fr/payslip/PayslipV3Test.java deleted file mode 100644 index a05071df1..000000000 --- a/src/test/java/com/mindee/product/fr/payslip/PayslipV3Test.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.mindee.product.fr.payslip; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for PayslipV3. - */ -public class PayslipV3Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, PayslipV3.class); - return objectMapper - .readValue( - new File(getV1ResourcePathString("products/payslip_fra/response_v3/" + name + ".json")), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - PayslipV3Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getPayPeriod().getEndDate()); - Assertions.assertNull(docPrediction.getPayPeriod().getMonth()); - Assertions.assertNull(docPrediction.getPayPeriod().getPaymentDate()); - Assertions.assertNull(docPrediction.getPayPeriod().getStartDate()); - Assertions.assertNull(docPrediction.getPayPeriod().getYear()); - Assertions.assertNull(docPrediction.getEmployee().getAddress()); - Assertions.assertNull(docPrediction.getEmployee().getDateOfBirth()); - Assertions.assertNull(docPrediction.getEmployee().getFirstName()); - Assertions.assertNull(docPrediction.getEmployee().getLastName()); - Assertions.assertNull(docPrediction.getEmployee().getPhoneNumber()); - Assertions.assertNull(docPrediction.getEmployee().getRegistrationNumber()); - Assertions.assertNull(docPrediction.getEmployee().getSocialSecurityNumber()); - Assertions.assertNull(docPrediction.getEmployer().getAddress()); - Assertions.assertNull(docPrediction.getEmployer().getCompanyId()); - Assertions.assertNull(docPrediction.getEmployer().getCompanySite()); - Assertions.assertNull(docPrediction.getEmployer().getNafCode()); - Assertions.assertNull(docPrediction.getEmployer().getName()); - Assertions.assertNull(docPrediction.getEmployer().getPhoneNumber()); - Assertions.assertNull(docPrediction.getEmployer().getUrssafNumber()); - Assertions.assertNull(docPrediction.getBankAccountDetails().getBankName()); - Assertions.assertNull(docPrediction.getBankAccountDetails().getIban()); - Assertions.assertNull(docPrediction.getBankAccountDetails().getSwift()); - Assertions.assertNull(docPrediction.getEmployment().getCategory()); - Assertions.assertNull(docPrediction.getEmployment().getCoefficient()); - Assertions.assertNull(docPrediction.getEmployment().getCollectiveAgreement()); - Assertions.assertNull(docPrediction.getEmployment().getJobTitle()); - Assertions.assertNull(docPrediction.getEmployment().getPositionLevel()); - Assertions.assertNull(docPrediction.getEmployment().getSeniorityDate()); - Assertions.assertNull(docPrediction.getEmployment().getStartDate()); - Assertions.assertTrue(docPrediction.getSalaryDetails().isEmpty()); - Assertions.assertNull(docPrediction.getPayDetail().getGrossSalary()); - Assertions.assertNull(docPrediction.getPayDetail().getGrossSalaryYtd()); - Assertions.assertNull(docPrediction.getPayDetail().getIncomeTaxRate()); - Assertions.assertNull(docPrediction.getPayDetail().getIncomeTaxWithheld()); - Assertions.assertNull(docPrediction.getPayDetail().getNetPaid()); - Assertions.assertNull(docPrediction.getPayDetail().getNetPaidBeforeTax()); - Assertions.assertNull(docPrediction.getPayDetail().getNetTaxable()); - Assertions.assertNull(docPrediction.getPayDetail().getNetTaxableYtd()); - Assertions.assertNull(docPrediction.getPayDetail().getTotalCostEmployer()); - Assertions.assertNull(docPrediction.getPayDetail().getTotalTaxesAndDeductions()); - Assertions.assertTrue(docPrediction.getPaidTimeOff().isEmpty()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/payslip_fra/response_v3/summary_full.rst") - ); - } - -} diff --git a/src/test/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Test.java b/src/test/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Test.java deleted file mode 100644 index 48eba9820..000000000 --- a/src/test/java/com/mindee/product/nutritionfactslabel/NutritionFactsLabelV1Test.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.mindee.product.nutritionfactslabel; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for NutritionFactsLabelV1. - */ -public class NutritionFactsLabelV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, NutritionFactsLabelV1.class); - return objectMapper - .readValue( - new File(getV1ResourcePathString("products/nutrition_facts/response_v1/" + name + ".json")), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - NutritionFactsLabelV1Document docPrediction = response - .getDocument() - .getInference() - .getPrediction(); - Assertions.assertNull(docPrediction.getServingPerBox().getValue()); - Assertions.assertNull(docPrediction.getServingSize().getAmount()); - Assertions.assertNull(docPrediction.getServingSize().getUnit()); - Assertions.assertNull(docPrediction.getCalories().getDailyValue()); - Assertions.assertNull(docPrediction.getCalories().getPer100G()); - Assertions.assertNull(docPrediction.getCalories().getPerServing()); - Assertions.assertNull(docPrediction.getTotalFat().getDailyValue()); - Assertions.assertNull(docPrediction.getTotalFat().getPer100G()); - Assertions.assertNull(docPrediction.getTotalFat().getPerServing()); - Assertions.assertNull(docPrediction.getSaturatedFat().getDailyValue()); - Assertions.assertNull(docPrediction.getSaturatedFat().getPer100G()); - Assertions.assertNull(docPrediction.getSaturatedFat().getPerServing()); - Assertions.assertNull(docPrediction.getTransFat().getDailyValue()); - Assertions.assertNull(docPrediction.getTransFat().getPer100G()); - Assertions.assertNull(docPrediction.getTransFat().getPerServing()); - Assertions.assertNull(docPrediction.getCholesterol().getDailyValue()); - Assertions.assertNull(docPrediction.getCholesterol().getPer100G()); - Assertions.assertNull(docPrediction.getCholesterol().getPerServing()); - Assertions.assertNull(docPrediction.getTotalCarbohydrate().getDailyValue()); - Assertions.assertNull(docPrediction.getTotalCarbohydrate().getPer100G()); - Assertions.assertNull(docPrediction.getTotalCarbohydrate().getPerServing()); - Assertions.assertNull(docPrediction.getDietaryFiber().getDailyValue()); - Assertions.assertNull(docPrediction.getDietaryFiber().getPer100G()); - Assertions.assertNull(docPrediction.getDietaryFiber().getPerServing()); - Assertions.assertNull(docPrediction.getTotalSugars().getDailyValue()); - Assertions.assertNull(docPrediction.getTotalSugars().getPer100G()); - Assertions.assertNull(docPrediction.getTotalSugars().getPerServing()); - Assertions.assertNull(docPrediction.getAddedSugars().getDailyValue()); - Assertions.assertNull(docPrediction.getAddedSugars().getPer100G()); - Assertions.assertNull(docPrediction.getAddedSugars().getPerServing()); - Assertions.assertNull(docPrediction.getProtein().getDailyValue()); - Assertions.assertNull(docPrediction.getProtein().getPer100G()); - Assertions.assertNull(docPrediction.getProtein().getPerServing()); - Assertions.assertNull(docPrediction.getSodium().getDailyValue()); - Assertions.assertNull(docPrediction.getSodium().getPer100G()); - Assertions.assertNull(docPrediction.getSodium().getPerServing()); - Assertions.assertNull(docPrediction.getSodium().getUnit()); - Assertions.assertTrue(docPrediction.getNutrients().isEmpty()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/nutrition_facts/response_v1/summary_full.rst") - ); - } - -} diff --git a/src/test/java/com/mindee/product/resume/ResumeV1Test.java b/src/test/java/com/mindee/product/resume/ResumeV1Test.java deleted file mode 100644 index 9d5bdcb80..000000000 --- a/src/test/java/com/mindee/product/resume/ResumeV1Test.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.mindee.product.resume; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for ResumeV1. - */ -public class ResumeV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, ResumeV1.class); - return objectMapper - .readValue( - new File(getV1ResourcePathString("products/resume/response_v1/" + name + ".json")), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - ResumeV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getDocumentLanguage().getValue()); - Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getDocumentType()); - Assertions.assertTrue(docPrediction.getGivenNames().isEmpty()); - Assertions.assertTrue(docPrediction.getSurnames().isEmpty()); - Assertions.assertNull(docPrediction.getNationality().getValue()); - Assertions.assertNull(docPrediction.getEmailAddress().getValue()); - Assertions.assertNull(docPrediction.getPhoneNumber().getValue()); - Assertions.assertNull(docPrediction.getAddress().getValue()); - Assertions.assertTrue(docPrediction.getSocialNetworksUrls().isEmpty()); - Assertions.assertNull(docPrediction.getProfession().getValue()); - Assertions.assertNull(docPrediction.getJobApplied().getValue()); - Assertions.assertTrue(docPrediction.getLanguages().isEmpty()); - Assertions.assertTrue(docPrediction.getHardSkills().isEmpty()); - Assertions.assertTrue(docPrediction.getSoftSkills().isEmpty()); - Assertions.assertTrue(docPrediction.getEducation().isEmpty()); - Assertions.assertTrue(docPrediction.getProfessionalExperiences().isEmpty()); - Assertions.assertTrue(docPrediction.getCertificates().isEmpty()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/resume/response_v1/summary_full.rst") - ); - } - -} diff --git a/src/test/java/com/mindee/product/us/bankcheck/BankCheckV1Test.java b/src/test/java/com/mindee/product/us/bankcheck/BankCheckV1Test.java deleted file mode 100644 index ca8a28933..000000000 --- a/src/test/java/com/mindee/product/us/bankcheck/BankCheckV1Test.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.mindee.product.us.bankcheck; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.Page; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for BankCheckV1. - */ -public class BankCheckV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, BankCheckV1.class); - return objectMapper - .readValue( - new File(getV1ResourcePathString("products/bank_check/response_v1/" + name + ".json")), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - BankCheckV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getDate().getValue()); - Assertions.assertNull(docPrediction.getAmount().getValue()); - Assertions.assertTrue(docPrediction.getPayees().isEmpty()); - Assertions.assertNull(docPrediction.getRoutingNumber().getValue()); - Assertions.assertNull(docPrediction.getAccountNumber().getValue()); - Assertions.assertNull(docPrediction.getCheckNumber().getValue()); - BankCheckV1Page pagePrediction = response - .getDocument() - .getInference() - .getPages() - .get(0) - .getPrediction(); - Assertions.assertEquals(pagePrediction.getCheckPosition().toString(), ""); - Assertions.assertTrue(pagePrediction.getSignaturesPositions().isEmpty()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/bank_check/response_v1/summary_full.rst") - ); - } - - @Test - void whenCompleteDeserialized_mustHaveValidPage0Summary() throws IOException { - PredictResponse response = getPrediction("complete"); - Page page = response.getDocument().getInference().getPages().get(0); - assertStringEqualsFile( - page.toString(), - getV1ResourcePathString("products/bank_check/response_v1/summary_page0.rst") - ); - } -} diff --git a/src/test/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Test.java b/src/test/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Test.java deleted file mode 100644 index 01332619e..000000000 --- a/src/test/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Test.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.mindee.product.us.healthcarecard; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for HealthcareCardV1. - */ -public class HealthcareCardV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, HealthcareCardV1.class); - return objectMapper - .readValue( - new File( - getV1ResourcePathString("products/us_healthcare_cards/response_v1/" + name + ".json") - ), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - HealthcareCardV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getCompanyName().getValue()); - Assertions.assertNull(docPrediction.getPlanName().getValue()); - Assertions.assertNull(docPrediction.getMemberName().getValue()); - Assertions.assertNull(docPrediction.getMemberId().getValue()); - Assertions.assertNull(docPrediction.getIssuer80840().getValue()); - Assertions.assertTrue(docPrediction.getDependents().isEmpty()); - Assertions.assertNull(docPrediction.getGroupNumber().getValue()); - Assertions.assertNull(docPrediction.getPayerId().getValue()); - Assertions.assertNull(docPrediction.getRxBin().getValue()); - Assertions.assertNull(docPrediction.getRxId().getValue()); - Assertions.assertNull(docPrediction.getRxGrp().getValue()); - Assertions.assertNull(docPrediction.getRxPcn().getValue()); - Assertions.assertTrue(docPrediction.getCopays().isEmpty()); - Assertions.assertNull(docPrediction.getEnrollmentDate().getValue()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/us_healthcare_cards/response_v1/summary_full.rst") - ); - } - -} diff --git a/src/test/java/com/mindee/product/us/usmail/UsMailV3Test.java b/src/test/java/com/mindee/product/us/usmail/UsMailV3Test.java deleted file mode 100644 index 1c1c947d3..000000000 --- a/src/test/java/com/mindee/product/us/usmail/UsMailV3Test.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.mindee.product.us.usmail; - -import static com.mindee.TestingUtilities.assertStringEqualsFile; -import static com.mindee.TestingUtilities.getV1ResourcePathString; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import java.io.File; -import java.io.IOException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Unit tests for UsMailV3. - */ -public class UsMailV3Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper - .getTypeFactory() - .constructParametricType(PredictResponse.class, UsMailV3.class); - return objectMapper - .readValue( - new File(getV1ResourcePathString("products/us_mail/response_v3/" + name + ".json")), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - UsMailV3Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getSenderName().getValue()); - Assertions.assertNull(docPrediction.getSenderAddress().getCity()); - Assertions.assertNull(docPrediction.getSenderAddress().getComplete()); - Assertions.assertNull(docPrediction.getSenderAddress().getPostalCode()); - Assertions.assertNull(docPrediction.getSenderAddress().getState()); - Assertions.assertNull(docPrediction.getSenderAddress().getStreet()); - Assertions.assertTrue(docPrediction.getRecipientNames().isEmpty()); - Assertions.assertTrue(docPrediction.getRecipientAddresses().isEmpty()); - Assertions.assertNull(docPrediction.getIsReturnToSender().getValue()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - assertStringEqualsFile( - doc.toString(), - getV1ResourcePathString("products/us_mail/response_v3/summary_full.rst") - ); - } - -} From 6ce39912674f71cb66211563d65d0b9fc6b0ff36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Fri, 3 Apr 2026 10:30:16 +0200 Subject: [PATCH 2/9] :recycle: :boom: rework v1 and v2 namespaces (#308) * :recycle: :boom: rework v1 and v2 namespaces * rework file operations * move settings * rework client * rename api classes --- docs/code_samples/bank_account_details_v2.txt | 6 +- docs/code_samples/barcode_reader_v1.txt | 6 +- docs/code_samples/carte_grise_v1.txt | 6 +- docs/code_samples/cropper_v1.txt | 6 +- docs/code_samples/default.txt | 8 +- docs/code_samples/default_async.txt | 8 +- docs/code_samples/driver_license_v1_async.txt | 6 +- docs/code_samples/expense_receipts_v5.txt | 6 +- .../expense_receipts_v5_async.txt | 6 +- docs/code_samples/financial_document_v1.txt | 6 +- .../financial_document_v1_async.txt | 6 +- docs/code_samples/idcard_fr_v1.txt | 6 +- docs/code_samples/idcard_fr_v2.txt | 6 +- docs/code_samples/ind_passport_v1_async.txt | 6 +- .../international_id_v2_async.txt | 6 +- .../invoice_splitter_v1_async.txt | 6 +- docs/code_samples/invoices_v4.txt | 6 +- docs/code_samples/invoices_v4_async.txt | 6 +- .../multi_receipts_detector_v1.txt | 6 +- docs/code_samples/passport_v1.txt | 6 +- docs/code_samples/v2_classification.txt | 4 +- docs/code_samples/v2_crop.txt | 4 +- docs/code_samples/v2_extraction.txt | 16 +-- docs/code_samples/v2_ocr.txt | 4 +- docs/code_samples/v2_split.txt | 4 +- docs/code_samples/workflow_execution.txt | 8 +- .../AutoInvoiceSplitterExtractionExample.java | 8 +- .../AutoMultiReceiptExtractionExample.java | 12 +- .../java/com/mindee/CommandLineInterface.java | 18 +-- .../java/com/mindee/geometry/Polygon.java | 48 +++++++- .../mindee/geometry/PolygonDeserializer.java | 2 +- .../com/mindee/geometry/PolygonUtils.java | 106 +----------------- .../mindee/geometry/PositionDataField.java | 8 ++ .../{extraction => image}/ExtractedImage.java | 10 +- .../{extraction => image}/ImageExtractor.java | 38 ++++--- .../java/com/mindee/input/LocalResponse.java | 14 +-- .../com/mindee/parsing/SummaryHelper.java | 17 +-- .../mindee/parsing/standard/PositionData.java | 12 -- .../{extraction => pdf}/ExtractedPDF.java | 2 +- .../{extraction => pdf}/PDFExtractor.java | 4 +- .../com/mindee/{ => v1}/MindeeClient.java | 34 +++--- .../com/mindee/{ => v1}/MindeeSettings.java | 2 +- .../cli/CommandLineInterfaceProducts.java | 32 +++--- .../mindee/{ => v1}/cli/ProductProcessor.java | 8 +- .../clientOptions}/PredictOptions.java | 2 +- .../clientOptions}/WorkflowOptions.java | 4 +- .../{ => v1}/http/CustomEndpointInfo.java | 2 +- .../com/mindee/{ => v1}/http/Endpoint.java | 4 +- .../mindee/{ => v1}/http/EndpointInfo.java | 2 +- .../http/MindeeApiV1.java} | 13 ++- .../http/MindeeHttpApiV1.java} | 30 ++--- .../http/MindeeHttpExceptionV1.java} | 6 +- .../{ => v1}/http/RequestParameters.java | 6 +- .../com/mindee/v1/parsing/SummaryHelper.java | 22 ++++ .../{ => v1}/parsing/common/ApiRequest.java | 2 +- .../{ => v1}/parsing/common/ApiResponse.java | 2 +- .../parsing/common/AsyncPredictResponse.java | 2 +- .../{ => v1}/parsing/common/Cropper.java | 4 +- .../{ => v1}/parsing/common/Document.java | 4 +- .../mindee/{ => v1}/parsing/common/Error.java | 2 +- .../{ => v1}/parsing/common/ErrorDetails.java | 2 +- .../common/ErrorDetailsDeserializer.java | 2 +- .../{ => v1}/parsing/common/Execution.java | 4 +- .../parsing/common/ExecutionFile.java | 2 +- .../parsing/common/ExecutionPriority.java | 2 +- .../{ => v1}/parsing/common/Extras.java | 2 +- .../{ => v1}/parsing/common/FullTextOcr.java | 2 +- .../{ => v1}/parsing/common/Inference.java | 4 +- .../parsing/common/InferenceExtras.java | 2 +- .../mindee/{ => v1}/parsing/common/Job.java | 2 +- .../common/LocalDateTimeDeserializer.java | 2 +- .../{ => v1}/parsing/common/Orientation.java | 2 +- .../mindee/{ => v1}/parsing/common/Page.java | 2 +- .../mindee/{ => v1}/parsing/common/Pages.java | 4 +- .../parsing/common/PredictResponse.java | 2 +- .../{ => v1}/parsing/common/Prediction.java | 2 +- .../{ => v1}/parsing/common/Product.java | 2 +- .../mindee/{ => v1}/parsing/common/Rag.java | 2 +- .../parsing/common/WorkflowResponse.java | 4 +- .../parsing/common/ocr/MvisionV1.java | 2 +- .../{ => v1}/parsing/common/ocr/Ocr.java | 2 +- .../{ => v1}/parsing/common/ocr/OcrPage.java | 8 +- .../{ => v1}/parsing/common/ocr/Word.java | 2 +- .../parsing/generated/GeneratedFeature.java | 24 ++-- .../parsing/generated/GeneratedObject.java | 35 +++--- .../GeneratedV1PredictionDeserializer.java | 4 +- .../parsing/standard/AddressField.java | 2 +- .../parsing/standard/AmountField.java | 4 +- .../{ => v1}/parsing/standard/BaseField.java | 5 +- .../parsing/standard/BooleanField.java | 4 +- .../parsing/standard/ClassificationField.java | 2 +- .../standard/CompanyRegistrationField.java | 4 +- .../{ => v1}/parsing/standard/DateField.java | 2 +- .../parsing/standard/LineItemField.java | 2 +- .../parsing/standard/LocaleField.java | 2 +- .../parsing/standard/PaymentDetailsField.java | 2 +- .../parsing/standard/PositionField.java | 5 +- .../parsing/standard/StringField.java | 4 +- .../{ => v1}/parsing/standard/TaxField.java | 4 +- .../{ => v1}/parsing/standard/Taxes.java | 4 +- .../parsing/standard/TaxesDeserializer.java | 2 +- .../barcodereader/BarcodeReaderV1.java | 6 +- .../BarcodeReaderV1Document.java | 8 +- .../{ => v1}/product/cropper/CropperV1.java | 6 +- .../product/cropper/CropperV1Document.java | 4 +- .../product/cropper/CropperV1Page.java | 6 +- .../driverlicense/DriverLicenseV1.java | 6 +- .../DriverLicenseV1Document.java | 10 +- .../FinancialDocumentV1.java | 6 +- .../FinancialDocumentV1Document.java | 26 ++--- .../FinancialDocumentV1LineItem.java | 8 +- .../BankAccountDetailsV2.java | 6 +- .../BankAccountDetailsV2Bban.java | 6 +- .../BankAccountDetailsV2Document.java | 8 +- .../product/fr/cartegrise/CarteGriseV1.java | 6 +- .../fr/cartegrise/CarteGriseV1Document.java | 10 +- .../{ => v1}/product/fr/idcard/IdCardV1.java | 6 +- .../product/fr/idcard/IdCardV1Document.java | 10 +- .../product/fr/idcard/IdCardV1Page.java | 6 +- .../{ => v1}/product/fr/idcard/IdCardV2.java | 6 +- .../product/fr/idcard/IdCardV2Document.java | 10 +- .../product/fr/idcard/IdCardV2Page.java | 6 +- .../product/generated/GeneratedV1.java | 4 +- .../generated/GeneratedV1Document.java | 8 +- .../ind/indianpassport/IndianPassportV1.java | 6 +- .../IndianPassportV1Document.java | 12 +- .../internationalid/InternationalIdV2.java | 6 +- .../InternationalIdV2Document.java | 12 +- .../{ => v1}/product/invoice/InvoiceV4.java | 6 +- .../product/invoice/InvoiceV4Document.java | 26 ++--- .../product/invoice/InvoiceV4LineItem.java | 8 +- .../invoicesplitter/InvoiceSplitterV1.java | 6 +- .../InvoiceSplitterV1Document.java | 6 +- .../InvoiceSplitterV1InvoicePageGroup.java | 6 +- .../MultiReceiptsDetectorV1.java | 6 +- .../MultiReceiptsDetectorV1Document.java | 8 +- .../{ => v1}/product/passport/PassportV1.java | 6 +- .../product/passport/PassportV1Document.java | 10 +- .../{ => v1}/product/receipt/ReceiptV5.java | 6 +- .../product/receipt/ReceiptV5Document.java | 22 ++-- .../product/receipt/ReceiptV5LineItem.java | 8 +- .../MindeeClient.java} | 57 +++++----- .../MindeeSettings.java} | 10 +- .../com/mindee/{ => v2}/http/MindeeApiV2.java | 10 +- .../mindee/{ => v2}/http/MindeeHttpApiV2.java | 17 ++- .../{ => v2}/http/MindeeHttpExceptionV2.java | 2 +- .../com/mindee/v2/parsing/BaseInference.java | 4 +- .../v2 => v2/parsing}/CommonResponse.java | 2 +- .../{parsing/v2 => v2/parsing}/ErrorItem.java | 2 +- .../v2 => v2/parsing}/ErrorResponse.java | 2 +- .../{parsing/v2 => v2/parsing}/Job.java | 4 +- .../v2 => v2/parsing}/JobResponse.java | 2 +- .../v2 => v2/parsing}/JobWebhook.java | 4 +- .../inference}/DataSchemaActiveOptions.java | 2 +- .../inference}/InferenceActiveOptions.java | 2 +- .../parsing/inference}/InferenceFile.java | 2 +- .../parsing/inference}/InferenceJob.java | 2 +- .../parsing/inference}/InferenceModel.java | 2 +- .../parsing/inference}/RagMetadata.java | 2 +- .../v2 => v2/parsing/inference}/RawText.java | 2 +- .../parsing/inference}/RawTextPage.java | 2 +- .../parsing/inference}/field/BaseField.java | 2 +- .../inference}/field/DynamicField.java | 2 +- .../field/DynamicFieldDeserializer.java | 2 +- .../inference}/field/FieldConfidence.java | 2 +- .../inference}/field/FieldLocation.java | 5 +- .../inference}/field/InferenceFields.java | 2 +- .../parsing/inference}/field/ListField.java | 2 +- .../parsing/inference}/field/ObjectField.java | 2 +- .../parsing/inference}/field/SimpleField.java | 2 +- .../field/SimpleFieldDeserializer.java | 2 +- .../ClassificationResponse.java | 2 +- .../com/mindee/v2/product/crop/CropItem.java | 2 +- .../mindee/v2/product/crop/CropResponse.java | 2 +- .../extraction/ExtractionInference.java} | 5 +- .../extraction/ExtractionResponse.java} | 7 +- .../product/extraction/ExtractionResult.java} | 8 +- .../params/ExtractionParameters.java} | 15 +-- .../mindee/v2/product/ocr/OcrResponse.java | 2 +- .../v2/product/split/SplitResponse.java | 2 +- .../com/mindee/geometry/PolygonUtilsTest.java | 65 ++++------- ...pApiTest.java => MindeeHttpApiV1Test.java} | 78 ++++++++----- .../ImageExtractorTest.java | 14 +-- .../com/mindee/input/LocalResponseV2Test.java | 4 +- .../com/mindee/input/URLInputSourceIT.java | 6 +- .../{extraction => pdf}/PDFExtractorTest.java | 6 +- .../com/mindee/{ => v1}/MindeeClientTest.java | 27 ++--- .../mindee/{ => v1}/MindeeSettingsTest.java | 2 +- .../InvoiceSplitterAutoExtractionIT.java | 16 +-- .../common/AsyncPredictResponseTest.java | 4 +- .../{ => v1}/parsing/common/CropperTest.java | 8 +- .../{ => v1}/parsing/common/ErrorTest.java | 8 +- .../parsing/common/FullTextOcrTest.java | 6 +- .../{ => v1}/parsing/common/OcrTest.java | 8 +- .../parsing/standard/DateFieldTest.java | 2 +- .../barcodereader/BarcodeReaderV1Test.java | 6 +- .../product/cropper/CropperV1Test.java | 8 +- .../driverlicense/DriverLicenseV1Test.java | 6 +- .../FinancialDocumentV1Test.java | 6 +- .../BankAccountDetailsV2Test.java | 6 +- .../fr/cartegrise/CarteGriseV1Test.java | 6 +- .../product/fr/idcard/IdCardV1Test.java | 10 +- .../product/fr/idcard/IdCardV2Test.java | 10 +- .../product/generated/GeneratedV1Test.java | 20 ++-- .../indianpassport/IndianPassportV1Test.java | 8 +- .../InternationalIdV2Test.java | 8 +- .../product/invoice/InvoiceV4Test.java | 8 +- .../InvoiceSplitterV1Test.java | 6 +- .../MultiReceiptsDetectorV1Test.java | 6 +- .../product/passport/PassportV1Test.java | 6 +- .../product/receipt/ReceiptV5Test.java | 8 +- .../mindee/{ => v1}/workflow/WorkflowIT.java | 20 ++-- .../{ => v1}/workflow/WorkflowTest.java | 16 +-- .../MindeeClientIT.java} | 64 ++++++----- .../MindeeClientTest.java} | 39 +++---- .../com/mindee/v2/MindeeSettingsTest.java | 17 +++ .../v2 => v2/parsing}/ExtractionTest.java | 89 ++++++++------- .../{parsing/v2 => v2/parsing}/JobTest.java | 2 +- .../java/com/mindee/v2/product/CropIT.java | 8 +- .../java/com/mindee/v2/product/SplitIT.java | 8 +- 220 files changed, 992 insertions(+), 1008 deletions(-) create mode 100644 src/main/java/com/mindee/geometry/PositionDataField.java rename src/main/java/com/mindee/{extraction => image}/ExtractedImage.java (97%) rename src/main/java/com/mindee/{extraction => image}/ImageExtractor.java (88%) delete mode 100644 src/main/java/com/mindee/parsing/standard/PositionData.java rename src/main/java/com/mindee/{extraction => pdf}/ExtractedPDF.java (97%) rename src/main/java/com/mindee/{extraction => pdf}/PDFExtractor.java (98%) rename src/main/java/com/mindee/{ => v1}/MindeeClient.java (97%) rename src/main/java/com/mindee/{ => v1}/MindeeSettings.java (98%) rename src/main/java/com/mindee/{ => v1}/cli/CommandLineInterfaceProducts.java (88%) rename src/main/java/com/mindee/{ => v1}/cli/ProductProcessor.java (94%) rename src/main/java/com/mindee/{ => v1/clientOptions}/PredictOptions.java (97%) rename src/main/java/com/mindee/{ => v1/clientOptions}/WorkflowOptions.java (91%) rename src/main/java/com/mindee/{ => v1}/http/CustomEndpointInfo.java (96%) rename src/main/java/com/mindee/{ => v1}/http/Endpoint.java (95%) rename src/main/java/com/mindee/{ => v1}/http/EndpointInfo.java (94%) rename src/main/java/com/mindee/{http/MindeeApi.java => v1/http/MindeeApiV1.java} (75%) rename src/main/java/com/mindee/{http/MindeeHttpApi.java => v1/http/MindeeHttpApiV1.java} (95%) rename src/main/java/com/mindee/{http/MindeeHttpException.java => v1/http/MindeeHttpExceptionV1.java} (76%) rename src/main/java/com/mindee/{ => v1}/http/RequestParameters.java (88%) create mode 100644 src/main/java/com/mindee/v1/parsing/SummaryHelper.java rename src/main/java/com/mindee/{ => v1}/parsing/common/ApiRequest.java (96%) rename src/main/java/com/mindee/{ => v1}/parsing/common/ApiResponse.java (94%) rename src/main/java/com/mindee/{ => v1}/parsing/common/AsyncPredictResponse.java (97%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Cropper.java (82%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Document.java (93%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Error.java (95%) rename src/main/java/com/mindee/{ => v1}/parsing/common/ErrorDetails.java (93%) rename src/main/java/com/mindee/{ => v1}/parsing/common/ErrorDetailsDeserializer.java (96%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Execution.java (96%) rename src/main/java/com/mindee/{ => v1}/parsing/common/ExecutionFile.java (95%) rename src/main/java/com/mindee/{ => v1}/parsing/common/ExecutionPriority.java (90%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Extras.java (93%) rename src/main/java/com/mindee/{ => v1}/parsing/common/FullTextOcr.java (93%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Inference.java (96%) rename src/main/java/com/mindee/{ => v1}/parsing/common/InferenceExtras.java (93%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Job.java (96%) rename src/main/java/com/mindee/{ => v1}/parsing/common/LocalDateTimeDeserializer.java (97%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Orientation.java (91%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Page.java (98%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Pages.java (92%) rename src/main/java/com/mindee/{ => v1}/parsing/common/PredictResponse.java (95%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Prediction.java (89%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Product.java (92%) rename src/main/java/com/mindee/{ => v1}/parsing/common/Rag.java (92%) rename src/main/java/com/mindee/{ => v1}/parsing/common/WorkflowResponse.java (89%) rename src/main/java/com/mindee/{ => v1}/parsing/common/ocr/MvisionV1.java (93%) rename src/main/java/com/mindee/{ => v1}/parsing/common/ocr/Ocr.java (90%) rename src/main/java/com/mindee/{ => v1}/parsing/common/ocr/OcrPage.java (91%) rename src/main/java/com/mindee/{ => v1}/parsing/common/ocr/Word.java (94%) rename src/main/java/com/mindee/{ => v1}/parsing/generated/GeneratedFeature.java (89%) rename src/main/java/com/mindee/{ => v1}/parsing/generated/GeneratedObject.java (89%) rename src/main/java/com/mindee/{ => v1}/parsing/generated/GeneratedV1PredictionDeserializer.java (95%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/AddressField.java (98%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/AmountField.java (92%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/BaseField.java (93%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/BooleanField.java (92%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/ClassificationField.java (93%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/CompanyRegistrationField.java (95%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/DateField.java (97%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/LineItemField.java (76%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/LocaleField.java (98%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/PaymentDetailsField.java (97%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/PositionField.java (91%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/StringField.java (93%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/TaxField.java (96%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/Taxes.java (88%) rename src/main/java/com/mindee/{ => v1}/parsing/standard/TaxesDeserializer.java (96%) rename src/main/java/com/mindee/{ => v1}/product/barcodereader/BarcodeReaderV1.java (73%) rename src/main/java/com/mindee/{ => v1}/product/barcodereader/BarcodeReaderV1Document.java (87%) rename src/main/java/com/mindee/{ => v1}/product/cropper/CropperV1.java (72%) rename src/main/java/com/mindee/{ => v1}/product/cropper/CropperV1Document.java (83%) rename src/main/java/com/mindee/{ => v1}/product/cropper/CropperV1Page.java (88%) rename src/main/java/com/mindee/{ => v1}/product/driverlicense/DriverLicenseV1.java (73%) rename src/main/java/com/mindee/{ => v1}/product/driverlicense/DriverLicenseV1Document.java (93%) rename src/main/java/com/mindee/{ => v1}/product/financialdocument/FinancialDocumentV1.java (73%) rename src/main/java/com/mindee/{ => v1}/product/financialdocument/FinancialDocumentV1Document.java (94%) rename src/main/java/com/mindee/{ => v1}/product/financialdocument/FinancialDocumentV1LineItem.java (95%) rename src/main/java/com/mindee/{ => v1}/product/fr/bankaccountdetails/BankAccountDetailsV2.java (73%) rename src/main/java/com/mindee/{ => v1}/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java (94%) rename src/main/java/com/mindee/{ => v1}/product/fr/bankaccountdetails/BankAccountDetailsV2Document.java (89%) rename src/main/java/com/mindee/{ => v1}/product/fr/cartegrise/CarteGriseV1.java (72%) rename src/main/java/com/mindee/{ => v1}/product/fr/cartegrise/CarteGriseV1Document.java (97%) rename src/main/java/com/mindee/{ => v1}/product/fr/idcard/IdCardV1.java (72%) rename src/main/java/com/mindee/{ => v1}/product/fr/idcard/IdCardV1Document.java (92%) rename src/main/java/com/mindee/{ => v1}/product/fr/idcard/IdCardV1Page.java (85%) rename src/main/java/com/mindee/{ => v1}/product/fr/idcard/IdCardV2.java (72%) rename src/main/java/com/mindee/{ => v1}/product/fr/idcard/IdCardV2Document.java (94%) rename src/main/java/com/mindee/{ => v1}/product/fr/idcard/IdCardV2Page.java (88%) rename src/main/java/com/mindee/{ => v1}/product/generated/GeneratedV1.java (77%) rename src/main/java/com/mindee/{ => v1}/product/generated/GeneratedV1Document.java (83%) rename src/main/java/com/mindee/{ => v1}/product/ind/indianpassport/IndianPassportV1.java (72%) rename src/main/java/com/mindee/{ => v1}/product/ind/indianpassport/IndianPassportV1Document.java (95%) rename src/main/java/com/mindee/{ => v1}/product/internationalid/InternationalIdV2.java (73%) rename src/main/java/com/mindee/{ => v1}/product/internationalid/InternationalIdV2Document.java (94%) rename src/main/java/com/mindee/{ => v1}/product/invoice/InvoiceV4.java (72%) rename src/main/java/com/mindee/{ => v1}/product/invoice/InvoiceV4Document.java (93%) rename src/main/java/com/mindee/{ => v1}/product/invoice/InvoiceV4LineItem.java (95%) rename src/main/java/com/mindee/{ => v1}/product/invoicesplitter/InvoiceSplitterV1.java (73%) rename src/main/java/com/mindee/{ => v1}/product/invoicesplitter/InvoiceSplitterV1Document.java (92%) rename src/main/java/com/mindee/{ => v1}/product/invoicesplitter/InvoiceSplitterV1InvoicePageGroup.java (91%) rename src/main/java/com/mindee/{ => v1}/product/multireceiptsdetector/MultiReceiptsDetectorV1.java (74%) rename src/main/java/com/mindee/{ => v1}/product/multireceiptsdetector/MultiReceiptsDetectorV1Document.java (83%) rename src/main/java/com/mindee/{ => v1}/product/passport/PassportV1.java (72%) rename src/main/java/com/mindee/{ => v1}/product/passport/PassportV1Document.java (93%) rename src/main/java/com/mindee/{ => v1}/product/receipt/ReceiptV5.java (72%) rename src/main/java/com/mindee/{ => v1}/product/receipt/ReceiptV5Document.java (91%) rename src/main/java/com/mindee/{ => v1}/product/receipt/ReceiptV5LineItem.java (93%) rename src/main/java/com/mindee/{MindeeClientV2.java => v2/MindeeClient.java} (80%) rename src/main/java/com/mindee/{MindeeSettingsV2.java => v2/MindeeSettings.java} (85%) rename src/main/java/com/mindee/{ => v2}/http/MindeeApiV2.java (92%) rename src/main/java/com/mindee/{ => v2}/http/MindeeHttpApiV2.java (95%) rename src/main/java/com/mindee/{ => v2}/http/MindeeHttpExceptionV2.java (95%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing}/CommonResponse.java (93%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing}/ErrorItem.java (95%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing}/ErrorResponse.java (97%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing}/Job.java (95%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing}/JobResponse.java (93%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing}/JobWebhook.java (91%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/DataSchemaActiveOptions.java (95%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/InferenceActiveOptions.java (97%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/InferenceFile.java (96%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/InferenceJob.java (94%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/InferenceModel.java (94%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/RagMetadata.java (92%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/RawText.java (95%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/RawTextPage.java (93%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/field/BaseField.java (92%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/field/DynamicField.java (98%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/field/DynamicFieldDeserializer.java (96%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/field/FieldConfidence.java (98%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/field/FieldLocation.java (85%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/field/InferenceFields.java (98%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/field/ListField.java (97%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/field/ObjectField.java (99%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/field/SimpleField.java (98%) rename src/main/java/com/mindee/{parsing/v2 => v2/parsing/inference}/field/SimpleFieldDeserializer.java (97%) rename src/main/java/com/mindee/{parsing/v2/Inference.java => v2/product/extraction/ExtractionInference.java} (81%) rename src/main/java/com/mindee/{parsing/v2/InferenceResponse.java => v2/product/extraction/ExtractionResponse.java} (67%) rename src/main/java/com/mindee/{parsing/v2/InferenceResult.java => v2/product/extraction/ExtractionResult.java} (81%) rename src/main/java/com/mindee/{InferenceParameters.java => v2/product/extraction/params/ExtractionParameters.java} (91%) rename src/test/java/com/mindee/http/{MindeeHttpApiTest.java => MindeeHttpApiV1Test.java} (88%) rename src/test/java/com/mindee/{extraction => image}/ImageExtractorTest.java (93%) rename src/test/java/com/mindee/{extraction => pdf}/PDFExtractorTest.java (95%) rename src/test/java/com/mindee/{ => v1}/MindeeClientTest.java (95%) rename src/test/java/com/mindee/{ => v1}/MindeeSettingsTest.java (96%) rename src/test/java/com/mindee/{extraction => v1/fileOperation}/InvoiceSplitterAutoExtractionIT.java (90%) rename src/test/java/com/mindee/{ => v1}/parsing/common/AsyncPredictResponseTest.java (97%) rename src/test/java/com/mindee/{ => v1}/parsing/common/CropperTest.java (85%) rename src/test/java/com/mindee/{ => v1}/parsing/common/ErrorTest.java (85%) rename src/test/java/com/mindee/{ => v1}/parsing/common/FullTextOcrTest.java (92%) rename src/test/java/com/mindee/{ => v1}/parsing/common/OcrTest.java (91%) rename src/test/java/com/mindee/{ => v1}/parsing/standard/DateFieldTest.java (94%) rename src/test/java/com/mindee/{ => v1}/product/barcodereader/BarcodeReaderV1Test.java (92%) rename src/test/java/com/mindee/{ => v1}/product/cropper/CropperV1Test.java (91%) rename src/test/java/com/mindee/{ => v1}/product/driverlicense/DriverLicenseV1Test.java (94%) rename src/test/java/com/mindee/{ => v1}/product/financialdocument/FinancialDocumentV1Test.java (98%) rename src/test/java/com/mindee/{ => v1}/product/fr/bankaccountdetails/BankAccountDetailsV2Test.java (93%) rename src/test/java/com/mindee/{ => v1}/product/fr/cartegrise/CarteGriseV1Test.java (96%) rename src/test/java/com/mindee/{ => v1}/product/fr/idcard/IdCardV1Test.java (92%) rename src/test/java/com/mindee/{ => v1}/product/fr/idcard/IdCardV2Test.java (93%) rename src/test/java/com/mindee/{ => v1}/product/generated/GeneratedV1Test.java (95%) rename src/test/java/com/mindee/{ => v1}/product/ind/indianpassport/IndianPassportV1Test.java (93%) rename src/test/java/com/mindee/{ => v1}/product/internationalid/InternationalIdV2Test.java (93%) rename src/test/java/com/mindee/{ => v1}/product/invoice/InvoiceV4Test.java (94%) rename src/test/java/com/mindee/{ => v1}/product/invoicesplitter/InvoiceSplitterV1Test.java (92%) rename src/test/java/com/mindee/{ => v1}/product/multireceiptsdetector/MultiReceiptsDetectorV1Test.java (92%) rename src/test/java/com/mindee/{ => v1}/product/passport/PassportV1Test.java (94%) rename src/test/java/com/mindee/{ => v1}/product/receipt/ReceiptV5Test.java (93%) rename src/test/java/com/mindee/{ => v1}/workflow/WorkflowIT.java (85%) rename src/test/java/com/mindee/{ => v1}/workflow/WorkflowTest.java (94%) rename src/test/java/com/mindee/{MindeeClientV2IT.java => v2/MindeeClientIT.java} (77%) rename src/test/java/com/mindee/{MindeeClientV2Test.java => v2/MindeeClientTest.java} (77%) create mode 100644 src/test/java/com/mindee/v2/MindeeSettingsTest.java rename src/test/java/com/mindee/{parsing/v2 => v2/parsing}/ExtractionTest.java (87%) rename src/test/java/com/mindee/{parsing/v2 => v2/parsing}/JobTest.java (98%) diff --git a/docs/code_samples/bank_account_details_v2.txt b/docs/code_samples/bank_account_details_v2.txt index 7965f8b3d..6e0682333 100644 --- a/docs/code_samples/bank_account_details_v2.txt +++ b/docs/code_samples/bank_account_details_v2.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.fr.bankaccountdetails.BankAccountDetailsV2; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.fr.bankaccountdetails.BankAccountDetailsV2; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/barcode_reader_v1.txt b/docs/code_samples/barcode_reader_v1.txt index 7d02437d7..b44cbacfa 100644 --- a/docs/code_samples/barcode_reader_v1.txt +++ b/docs/code_samples/barcode_reader_v1.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.barcodereader.BarcodeReaderV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.barcodereader.BarcodeReaderV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/carte_grise_v1.txt b/docs/code_samples/carte_grise_v1.txt index b95b3c542..fabb8ae1d 100644 --- a/docs/code_samples/carte_grise_v1.txt +++ b/docs/code_samples/carte_grise_v1.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.fr.cartegrise.CarteGriseV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.fr.cartegrise.CarteGriseV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/cropper_v1.txt b/docs/code_samples/cropper_v1.txt index ebfe63583..906d1af16 100644 --- a/docs/code_samples/cropper_v1.txt +++ b/docs/code_samples/cropper_v1.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.cropper.CropperV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.cropper.CropperV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/default.txt b/docs/code_samples/default.txt index eb497b35d..5ff7a6452 100644 --- a/docs/code_samples/default.txt +++ b/docs/code_samples/default.txt @@ -1,8 +1,8 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.generated.GeneratedV1; -import com.mindee.http.Endpoint; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.generated.GeneratedV1; +import com.mindee.v1.http.Endpoint; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/default_async.txt b/docs/code_samples/default_async.txt index 11039520e..735c0e02d 100644 --- a/docs/code_samples/default_async.txt +++ b/docs/code_samples/default_async.txt @@ -1,8 +1,8 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.generated.GeneratedV1; -import com.mindee.http.Endpoint; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.product.generated.GeneratedV1; +import com.mindee.v1.http.Endpoint; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/driver_license_v1_async.txt b/docs/code_samples/driver_license_v1_async.txt index ff91d52a8..ff8114bb3 100644 --- a/docs/code_samples/driver_license_v1_async.txt +++ b/docs/code_samples/driver_license_v1_async.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.driverlicense.DriverLicenseV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.product.driverlicense.DriverLicenseV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/expense_receipts_v5.txt b/docs/code_samples/expense_receipts_v5.txt index 07390d160..21a66f4f7 100644 --- a/docs/code_samples/expense_receipts_v5.txt +++ b/docs/code_samples/expense_receipts_v5.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.receipt.ReceiptV5; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.receipt.ReceiptV5; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/expense_receipts_v5_async.txt b/docs/code_samples/expense_receipts_v5_async.txt index c6fe76144..b2e797982 100644 --- a/docs/code_samples/expense_receipts_v5_async.txt +++ b/docs/code_samples/expense_receipts_v5_async.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.receipt.ReceiptV5; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.product.receipt.ReceiptV5; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/financial_document_v1.txt b/docs/code_samples/financial_document_v1.txt index f9e269c5f..73fda927b 100644 --- a/docs/code_samples/financial_document_v1.txt +++ b/docs/code_samples/financial_document_v1.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.financialdocument.FinancialDocumentV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.financialdocument.FinancialDocumentV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/financial_document_v1_async.txt b/docs/code_samples/financial_document_v1_async.txt index 2de07a924..1370a6416 100644 --- a/docs/code_samples/financial_document_v1_async.txt +++ b/docs/code_samples/financial_document_v1_async.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.financialdocument.FinancialDocumentV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.product.financialdocument.FinancialDocumentV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/idcard_fr_v1.txt b/docs/code_samples/idcard_fr_v1.txt index c760517d7..7e531ecd7 100644 --- a/docs/code_samples/idcard_fr_v1.txt +++ b/docs/code_samples/idcard_fr_v1.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.fr.idcard.IdCardV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.fr.idcard.IdCardV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/idcard_fr_v2.txt b/docs/code_samples/idcard_fr_v2.txt index 15ad29781..88d22f1b1 100644 --- a/docs/code_samples/idcard_fr_v2.txt +++ b/docs/code_samples/idcard_fr_v2.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.fr.idcard.IdCardV2; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.fr.idcard.IdCardV2; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/ind_passport_v1_async.txt b/docs/code_samples/ind_passport_v1_async.txt index 2bde854cd..b64965cda 100644 --- a/docs/code_samples/ind_passport_v1_async.txt +++ b/docs/code_samples/ind_passport_v1_async.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.ind.indianpassport.IndianPassportV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.product.ind.indianpassport.IndianPassportV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/international_id_v2_async.txt b/docs/code_samples/international_id_v2_async.txt index e12c1774b..3b6956c4f 100644 --- a/docs/code_samples/international_id_v2_async.txt +++ b/docs/code_samples/international_id_v2_async.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.internationalid.InternationalIdV2; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.product.internationalid.InternationalIdV2; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/invoice_splitter_v1_async.txt b/docs/code_samples/invoice_splitter_v1_async.txt index 69abfa569..ccbf64cf4 100644 --- a/docs/code_samples/invoice_splitter_v1_async.txt +++ b/docs/code_samples/invoice_splitter_v1_async.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.invoicesplitter.InvoiceSplitterV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.product.invoicesplitter.InvoiceSplitterV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/invoices_v4.txt b/docs/code_samples/invoices_v4.txt index cb472586c..5d666e865 100644 --- a/docs/code_samples/invoices_v4.txt +++ b/docs/code_samples/invoices_v4.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; +import com.mindee.v1.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.invoice.InvoiceV4; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.invoice.InvoiceV4; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/invoices_v4_async.txt b/docs/code_samples/invoices_v4_async.txt index 51caddb3a..ac52fd1be 100644 --- a/docs/code_samples/invoices_v4_async.txt +++ b/docs/code_samples/invoices_v4_async.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; +import com.mindee.v1.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.invoice.InvoiceV4; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.product.invoice.InvoiceV4; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/multi_receipts_detector_v1.txt b/docs/code_samples/multi_receipts_detector_v1.txt index 190e9bfb0..ec02e88e2 100644 --- a/docs/code_samples/multi_receipts_detector_v1.txt +++ b/docs/code_samples/multi_receipts_detector_v1.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.multireceiptsdetector.MultiReceiptsDetectorV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.multireceiptsdetector.MultiReceiptsDetectorV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/passport_v1.txt b/docs/code_samples/passport_v1.txt index 9b3cb1950..9ae473641 100644 --- a/docs/code_samples/passport_v1.txt +++ b/docs/code_samples/passport_v1.txt @@ -1,7 +1,7 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.passport.PassportV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.passport.PassportV1; import java.io.File; import java.io.IOException; diff --git a/docs/code_samples/v2_classification.txt b/docs/code_samples/v2_classification.txt index fc9339c84..f958f86e8 100644 --- a/docs/code_samples/v2_classification.txt +++ b/docs/code_samples/v2_classification.txt @@ -1,5 +1,5 @@ -import com.mindee.MindeeClientV2; import com.mindee.input.LocalInputSource; +import com.mindee.v2.MindeeClient; import com.mindee.v2.product.classification.ClassificationClassifier; import com.mindee.v2.product.classification.ClassificationResponse; import com.mindee.v2.product.classification.ClassificationResult; @@ -16,7 +16,7 @@ public class SimpleMindeeClientV2 { String modelId = "MY_MODEL_ID"; // Init a new client - MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey); + MindeeClient mindeeClient = new MindeeClient(apiKey); // Set inference parameters // Note: modelId is mandatory. diff --git a/docs/code_samples/v2_crop.txt b/docs/code_samples/v2_crop.txt index 3d80e5751..b7a9af692 100644 --- a/docs/code_samples/v2_crop.txt +++ b/docs/code_samples/v2_crop.txt @@ -1,5 +1,5 @@ -import com.mindee.MindeeClientV2; import com.mindee.input.LocalInputSource; +import com.mindee.v2.MindeeClient; import com.mindee.v2.product.crop.CropResponse; import com.mindee.v2.product.crop.CropResult; import com.mindee.v2.product.crop.params.CropParameters; @@ -15,7 +15,7 @@ public class SimpleMindeeClientV2 { String modelId = "MY_MODEL_ID"; // Init a new client - MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey); + MindeeClient mindeeClient = new MindeeClient(apiKey); // Set inference parameters CropParameters cropParams = CropParameters diff --git a/docs/code_samples/v2_extraction.txt b/docs/code_samples/v2_extraction.txt index 954b550c4..bcfba5ed9 100644 --- a/docs/code_samples/v2_extraction.txt +++ b/docs/code_samples/v2_extraction.txt @@ -1,8 +1,8 @@ -import com.mindee.MindeeClientV2; -import com.mindee.InferenceParameters; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.v2.InferenceResponse; -import com.mindee.parsing.v2.field.InferenceFields; +import com.mindee.v2.MindeeClient; +import com.mindee.v2.product.extraction.params.ExtractionParameters; +import com.mindee.v2.product.extraction.ExtractionResponse; +import com.mindee.v2.parsing.inference.field.InferenceFields; import java.io.IOException; public class SimpleMindeeClientV2 { @@ -15,10 +15,10 @@ public class SimpleMindeeClientV2 { String modelId = "MY_MODEL_ID"; // Init a new client - MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey); + MindeeClient mindeeClient = new MindeeClient(apiKey); // Set inference parameters - InferenceParameters extractionParams = InferenceParameters + ExtractionParameters extractionParams = ExtractionParameters // ID of the model, required. .builder(modelId) @@ -40,8 +40,8 @@ public class SimpleMindeeClientV2 { LocalInputSource inputSource = new LocalInputSource(filePath); // Send for processing using polling - InferenceResponse response = mindeeClient.enqueueAndGetResult( - InferenceResponse.class, + ExtractionResponse response = mindeeClient.enqueueAndGetResult( + ExtractionResponse.class, inputSource, extractionParams ); diff --git a/docs/code_samples/v2_ocr.txt b/docs/code_samples/v2_ocr.txt index 95c676021..2401b2ddf 100644 --- a/docs/code_samples/v2_ocr.txt +++ b/docs/code_samples/v2_ocr.txt @@ -1,5 +1,5 @@ -import com.mindee.MindeeClientV2; import com.mindee.input.LocalInputSource; +import com.mindee.v2.MindeeClient; import com.mindee.v2.product.ocr.OcrResponse; import com.mindee.v2.product.ocr.OcrResult; import com.mindee.v2.product.ocr.params.OcrParameters; @@ -15,7 +15,7 @@ public class SimpleMindeeClientV2 { String modelId = "MY_MODEL_ID"; // Init a new client - MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey); + MindeeClient mindeeClient = new MindeeClient(apiKey); // Set inference parameters OcrParameters ocrParams = OcrParameters diff --git a/docs/code_samples/v2_split.txt b/docs/code_samples/v2_split.txt index b71623d36..a6acd3d29 100644 --- a/docs/code_samples/v2_split.txt +++ b/docs/code_samples/v2_split.txt @@ -1,5 +1,5 @@ -import com.mindee.MindeeClientV2; import com.mindee.input.LocalInputSource; +import com.mindee.v2.MindeeClient; import com.mindee.v2.product.split.SplitResponse; import com.mindee.v2.product.split.SplitResult; import com.mindee.v2.product.split.params.SplitParameters; @@ -15,7 +15,7 @@ public class SimpleMindeeClientV2 { String modelId = "MY_MODEL_ID"; // Init a new client - MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey); + MindeeClient mindeeClient = new MindeeClient(apiKey); // Set inference parameters SplitParameters splitParams = SplitParameters diff --git a/docs/code_samples/workflow_execution.txt b/docs/code_samples/workflow_execution.txt index 86390e51f..2f2dce7b0 100644 --- a/docs/code_samples/workflow_execution.txt +++ b/docs/code_samples/workflow_execution.txt @@ -1,8 +1,8 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.WorkflowResponse; -import com.mindee.product.generated.GeneratedV1; -import com.mindee.http.MindeeHttpException; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.WorkflowResponse; +import com.mindee.v1.product.generated.GeneratedV1; +import com.mindee.v1.http.MindeeHttpExceptionV1; import java.io.IOException; public class SimpleMindeeClientV1 { diff --git a/example/AutoInvoiceSplitterExtractionExample.java b/example/AutoInvoiceSplitterExtractionExample.java index 292a21a11..5b2a0c4ca 100644 --- a/example/AutoInvoiceSplitterExtractionExample.java +++ b/example/AutoInvoiceSplitterExtractionExample.java @@ -1,10 +1,10 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; import com.mindee.extraction.ExtractedPDF; import com.mindee.extraction.PDFExtractor; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.invoice.InvoiceV4; -import com.mindee.product.invoicesplitter.InvoiceSplitterV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.product.invoice.InvoiceV4; +import com.mindee.v1.product.invoicesplitter.InvoiceSplitterV1; import java.io.File; import java.io.IOException; diff --git a/example/AutoMultiReceiptExtractionExample.java b/example/AutoMultiReceiptExtractionExample.java index f079bbdd1..bf3553d4c 100644 --- a/example/AutoMultiReceiptExtractionExample.java +++ b/example/AutoMultiReceiptExtractionExample.java @@ -1,12 +1,12 @@ -import com.mindee.MindeeClient; import com.mindee.input.LocalInputSource; import com.mindee.extraction.ExtractedImage; import com.mindee.extraction.ImageExtractor; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.common.Page; -import com.mindee.product.multireceiptsdetector.MultiReceiptsDetectorV1; -import com.mindee.product.multireceiptsdetector.MultiReceiptsDetectorV1Document; -import com.mindee.product.receipt.ReceiptV5; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.Page; +import com.mindee.v1.product.multireceiptsdetector.MultiReceiptsDetectorV1; +import com.mindee.v1.product.multireceiptsdetector.MultiReceiptsDetectorV1Document; +import com.mindee.v1.product.receipt.ReceiptV5; import java.io.File; import java.io.IOException; diff --git a/src/main/java/com/mindee/CommandLineInterface.java b/src/main/java/com/mindee/CommandLineInterface.java index 2a02648a9..d4957ada6 100644 --- a/src/main/java/com/mindee/CommandLineInterface.java +++ b/src/main/java/com/mindee/CommandLineInterface.java @@ -1,16 +1,18 @@ package com.mindee; -import com.mindee.cli.CommandLineInterfaceProducts; -import com.mindee.cli.ProductProcessor; -import com.mindee.http.Endpoint; import com.mindee.input.LocalInputSource; import com.mindee.input.PageOptions; import com.mindee.input.PageOptionsOperation; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.parsing.common.Inference; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.common.ocr.Ocr; -import com.mindee.product.generated.GeneratedV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.cli.CommandLineInterfaceProducts; +import com.mindee.v1.cli.ProductProcessor; +import com.mindee.v1.clientOptions.PredictOptions; +import com.mindee.v1.http.Endpoint; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.Inference; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.ocr.Ocr; +import com.mindee.v1.product.generated.GeneratedV1; import java.io.File; import java.io.IOException; import java.lang.reflect.Method; diff --git a/src/main/java/com/mindee/geometry/Polygon.java b/src/main/java/com/mindee/geometry/Polygon.java index e01985e78..168fbb6f2 100644 --- a/src/main/java/com/mindee/geometry/Polygon.java +++ b/src/main/java/com/mindee/geometry/Polygon.java @@ -2,8 +2,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.ArrayList; +import java.util.Collection; import java.util.List; -import lombok.Builder; +import java.util.stream.Collectors; import lombok.Getter; /** @@ -17,7 +18,19 @@ public class Polygon { */ private List coordinates = new ArrayList<>(); - @Builder + /** + * Create a Polygon from a list of a list of floats. + */ + public Polygon(Collection> coordinates) { + this.coordinates = coordinates + .stream() + .map(coordinate -> new Point(coordinate.get(0), coordinate.get(1))) + .collect(Collectors.toList()); + } + + /** + * Create a Polygon from a list of Points. + */ public Polygon(List coordinates) { this.coordinates = coordinates; } @@ -82,6 +95,37 @@ public String toStringPrecise() { return builder.toString(); } + /** + * Compare two polygons based on their Y coordinates. + * Useful for sorting lists. + */ + public int compareOnY(Polygon polygon2) { + double sort = this.getMinMaxY().getMin() - polygon2.getMinMaxY().getMin(); + if (sort == 0) { + return 0; + } + return sort < 0 ? -1 : 1; + } + + /** + * Compare two polygons based on their X coordinates. + * Useful for sorting lists. + */ + public int compareOnX(Polygon polygon2) { + double sort = this.getMinMaxX().getMin() - polygon2.getMinMaxX().getMin(); + if (sort == 0) { + return 0; + } + return sort < 0 ? -1 : 1; + } + + /** + * Merge the coordinates of the two polygons. + */ + public Polygon combine(Polygon target) { + return PolygonUtils.combine(this, target); + } + @Override public boolean equals(Object object) { if (this == object) { diff --git a/src/main/java/com/mindee/geometry/PolygonDeserializer.java b/src/main/java/com/mindee/geometry/PolygonDeserializer.java index 22b4ead3b..42a9e6ae7 100644 --- a/src/main/java/com/mindee/geometry/PolygonDeserializer.java +++ b/src/main/java/com/mindee/geometry/PolygonDeserializer.java @@ -35,6 +35,6 @@ public Polygon deserialize( }; List> polygonList = mapper.readerFor(typeRef).readValue(node); - return PolygonUtils.getFrom(polygonList); + return new Polygon(polygonList); } } diff --git a/src/main/java/com/mindee/geometry/PolygonUtils.java b/src/main/java/com/mindee/geometry/PolygonUtils.java index ee32a294f..dd5a8c977 100644 --- a/src/main/java/com/mindee/geometry/PolygonUtils.java +++ b/src/main/java/com/mindee/geometry/PolygonUtils.java @@ -3,27 +3,16 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.OptionalDouble; import java.util.stream.Collectors; /** * Methods for working with Polygons. + * Used internally, use at your own risk. */ public final class PolygonUtils { private PolygonUtils() { } - /** - * Create a Polygon from a list of a list of floats. - */ - public static Polygon getFrom(List> polygon) { - List coordinates = polygon - .stream() - .map(coordinate -> new Point(coordinate.get(0), coordinate.get(1))) - .collect(Collectors.toList()); - return new Polygon(coordinates); - } - /** * Get the central coordinates (centroid) of a list of Points. */ @@ -35,30 +24,6 @@ public static Point getCentroid(List vertices) { return new Point(xSum / verticesSum, ySum / verticesSum); } - /** - * Compare two polygons based on their Y coordinates. - * Useful for sorting lists. - */ - public static int CompareOnY(Polygon polygon1, Polygon polygon2) { - double sort = getMinYCoordinate(polygon1) - getMinYCoordinate(polygon2); - if (sort == 0) { - return 0; - } - return sort < 0 ? -1 : 1; - } - - /** - * Compare two polygons based on their X coordinates. - * Useful for sorting lists. - */ - public static int CompareOnX(Polygon polygon1, Polygon polygon2) { - double sort = getMinXCoordinate(polygon1) - getMinXCoordinate(polygon2); - if (sort == 0) { - return 0; - } - return sort < 0 ? -1 : 1; - } - /** * Get the maximum and minimum Y coordinates in a given list of Points. */ @@ -90,75 +55,6 @@ public static boolean isPointInPolygonY(Point centroid, Polygon polygon) { return isPointInY(centroid, yCoords.getMin(), yCoords.getMax()); } - public static Double getMinYCoordinate(Polygon polygon) { - OptionalDouble min = polygon - .getCoordinates() - .stream() - .map(Point::getY) - .mapToDouble(Double::doubleValue) - .min(); - - if (min.isPresent()) { - return min.getAsDouble(); - } - - throw new IllegalStateException( - "The min Y could not be found " - + "because it seems that there is no coordinates in the current polygon." - ); - } - - public static Double getMaxYCoordinate(Polygon polygon) { - OptionalDouble max = polygon - .getCoordinates() - .stream() - .map(Point::getY) - .mapToDouble(Double::doubleValue) - .max(); - if (max.isPresent()) { - return max.getAsDouble(); - } - - throw new IllegalStateException( - "The max Y could not be found " - + "because it seems that there is no coordinates in the current polygon." - ); - } - - public static Double getMinXCoordinate(Polygon polygon) { - OptionalDouble min = polygon - .getCoordinates() - .stream() - .map(Point::getX) - .mapToDouble(Double::doubleValue) - .min(); - if (min.isPresent()) { - return min.getAsDouble(); - } - - throw new IllegalStateException( - "The min X could not be found " - + "because it seems that there is no coordinates in the current polygon." - ); - } - - public static Double getMaxXCoordinate(Polygon polygon) { - OptionalDouble max = polygon - .getCoordinates() - .stream() - .map(Point::getX) - .mapToDouble(Double::doubleValue) - .max(); - if (max.isPresent()) { - return max.getAsDouble(); - } - - throw new IllegalStateException( - "The max X could not be found " - + "because it seems that there is no coordinates in the current polygon." - ); - } - /** * Merge the coordinates of the two polygons. */ diff --git a/src/main/java/com/mindee/geometry/PositionDataField.java b/src/main/java/com/mindee/geometry/PositionDataField.java new file mode 100644 index 000000000..228e8d304 --- /dev/null +++ b/src/main/java/com/mindee/geometry/PositionDataField.java @@ -0,0 +1,8 @@ +package com.mindee.geometry; + +/** + * A field with position data. + */ +public interface PositionDataField { + Polygon getPolygon(); +} diff --git a/src/main/java/com/mindee/extraction/ExtractedImage.java b/src/main/java/com/mindee/image/ExtractedImage.java similarity index 97% rename from src/main/java/com/mindee/extraction/ExtractedImage.java rename to src/main/java/com/mindee/image/ExtractedImage.java index e5e383238..76540a8a3 100644 --- a/src/main/java/com/mindee/extraction/ExtractedImage.java +++ b/src/main/java/com/mindee/image/ExtractedImage.java @@ -1,4 +1,4 @@ -package com.mindee.extraction; +package com.mindee.image; import com.mindee.input.LocalInputSource; import java.awt.image.BufferedImage; @@ -21,7 +21,7 @@ public class ExtractedImage { /** * Default constructor. - * + * * @param image Buffered image object. * @param filename Name of the extracted image. * @param saveFormat Format to save the image as, defaults to PNG. @@ -35,7 +35,7 @@ public ExtractedImage(BufferedImage image, String filename, String saveFormat) { /** * Write the image to a file. * Uses the default image format and filename. - * + * * @param outputPath the output directory (must exist). * @throws IOException Throws if the file can't be accessed. */ @@ -48,7 +48,7 @@ public void writeToFile(String outputPath) throws IOException { /** * Write the image to a file. * Uses the default image format and filename. - * + * * @param outputPath the output directory (must exist). * @throws IOException Throws if the file can't be accessed. */ @@ -60,7 +60,7 @@ public void writeToFile(Path outputPath) throws IOException { /** * Return the image in a format suitable for sending to MindeeClient for parsing. - * + * * @return an instance of {@link LocalInputSource} * @throws IOException Throws if the file can't be accessed. */ diff --git a/src/main/java/com/mindee/extraction/ImageExtractor.java b/src/main/java/com/mindee/image/ImageExtractor.java similarity index 88% rename from src/main/java/com/mindee/extraction/ImageExtractor.java rename to src/main/java/com/mindee/image/ImageExtractor.java index 403d497e2..8dcb6b181 100644 --- a/src/main/java/com/mindee/extraction/ImageExtractor.java +++ b/src/main/java/com/mindee/image/ImageExtractor.java @@ -1,11 +1,10 @@ -package com.mindee.extraction; +package com.mindee.image; import com.mindee.geometry.Bbox; -import com.mindee.geometry.BboxUtils; import com.mindee.geometry.Polygon; +import com.mindee.geometry.PositionDataField; import com.mindee.input.InputSourceUtils; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.standard.PositionData; import com.mindee.pdf.PDFUtils; import com.mindee.pdf.PdfPageImage; import java.awt.image.BufferedImage; @@ -25,7 +24,7 @@ public class ImageExtractor { /** * Init from a path. - * + * * @param filePath Path to the file. * @throws IOException Throws if the file can't be accessed. */ @@ -35,7 +34,7 @@ public ImageExtractor(String filePath) throws IOException { /** * Init from a {@link LocalInputSource}. - * + * * @param source The local source. * @throws IOException Throws if the file can't be accessed. */ @@ -69,13 +68,13 @@ public int getPageCount() { /** * Extract multiple images on a given page from a list of fields having position data. - * + * * @param Type of field (needs to support positioning data). * @param fields List of Fields to extract. * @param pageIndex The page index to extract, begins at 0. * @return A list of {@link ExtractedImage}. */ - public List extractImagesFromPage( + public List extractImagesFromPage( List fields, int pageIndex ) { @@ -84,14 +83,14 @@ public List extractImagesFromPage( /** * Extract multiple images on a given page from a list of fields having position data. - * + * * @param Type of field (needs to support positioning data). * @param fields List of Fields to extract. * @param pageIndex The page index to extract, begins at 0. * @param outputName The base output filename, must have an image extension. * @return A list of {@link ExtractedImage}. */ - public List extractImagesFromPage( + public List extractImagesFromPage( List fields, int pageIndex, String outputName @@ -106,7 +105,7 @@ public List extractImagesFromPage( return extractFromPage(fields, pageIndex, filename); } - private List extractFromPage( + private List extractFromPage( List fields, int pageIndex, String outputName @@ -128,7 +127,7 @@ private List extractFromPage( /** * Extract a single image from a field having position data. - * + * * @param Type of field (needs to support positioning data). * @param field The field to extract. * @param index The index to use for naming the extracted image. @@ -137,7 +136,7 @@ private List extractFromPage( * @return The {@link ExtractedImage}, or null if the field does not have valid * position data. */ - public ExtractedImage extractImage( + public ExtractedImage extractImage( FieldT field, int pageIndex, int index, @@ -145,21 +144,24 @@ public ExtractedImage extractImage( ) { String[] splitName = InputSourceUtils.splitNameStrict(filename); String saveFormat = splitName[1].toLowerCase(); - Polygon boundingBox = field.getBoundingBox(); - if (boundingBox == null) { + Polygon polygon = field.getPolygon(); + if (polygon == null) { return null; } - Bbox bbox = BboxUtils.generate(boundingBox); String fieldFilename = splitName[0] + String.format("_%3s", index).replace(" ", "0") + "." + saveFormat; - return new ExtractedImage(extractImage(bbox, pageIndex), fieldFilename, saveFormat); + return new ExtractedImage( + extractImage(polygon.getAsBbox(), pageIndex), + fieldFilename, + saveFormat + ); } /** * Extract a single image from a field having position data. - * + * * @param Type of field (needs to support positioning data). * @param field The field to extract. * @param index The index to use for naming the extracted image. @@ -167,7 +169,7 @@ public ExtractedImage extractImage( * @return The {@link ExtractedImage}, or null if the field does not have valid * position data. */ - public ExtractedImage extractImage( + public ExtractedImage extractImage( FieldT field, int pageIndex, int index diff --git a/src/main/java/com/mindee/input/LocalResponse.java b/src/main/java/com/mindee/input/LocalResponse.java index bddbafd89..3eabd1423 100644 --- a/src/main/java/com/mindee/input/LocalResponse.java +++ b/src/main/java/com/mindee/input/LocalResponse.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.mindee.MindeeException; -import com.mindee.parsing.v2.CommonResponse; +import com.mindee.v2.parsing.CommonResponse; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -30,7 +30,7 @@ public class LocalResponse { /** * Load from an {@link InputStream}. - * + * * @param input will be decoded as UTF-8. */ public LocalResponse(InputStream input) { @@ -40,7 +40,7 @@ public LocalResponse(InputStream input) { /** * Load from a {@link String}. - * + * * @param input will be decoded as UTF-8. */ public LocalResponse(String input) { @@ -49,7 +49,7 @@ public LocalResponse(String input) { /** * Load from a {@link File}. - * + * * @param input will be decoded as UTF-8. */ public LocalResponse(File input) throws IOException { @@ -58,7 +58,7 @@ public LocalResponse(File input) throws IOException { /** * Load from a {@link Path}. - * + * * @param input will be decoded as UTF-8. */ public LocalResponse(Path input) throws IOException { @@ -71,7 +71,7 @@ private byte[] getBytes(Stream stream) { /** * Get the HMAC signature of the payload. - * + * * @param secretKey Your secret key from the Mindee platform. * @return The generated HMAC signature. */ @@ -98,7 +98,7 @@ public String getHmacSignature(String secretKey) { /** * Verify that the payload's signature matches the one received from the server. - * + * * @param secretKey Your secret key from the Mindee platform. * @param signature The signature from the "X-Mindee-Hmac-Signature" HTTP header. * @return true if the signatures match. diff --git a/src/main/java/com/mindee/parsing/SummaryHelper.java b/src/main/java/com/mindee/parsing/SummaryHelper.java index eaf27baad..dd6cb7f24 100644 --- a/src/main/java/com/mindee/parsing/SummaryHelper.java +++ b/src/main/java/com/mindee/parsing/SummaryHelper.java @@ -1,6 +1,5 @@ package com.mindee.parsing; -import com.mindee.parsing.standard.LineItemField; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.List; @@ -10,8 +9,8 @@ /** * Various static methods to help generate the prediction summaries. */ -public final class SummaryHelper { - private SummaryHelper() { +public class SummaryHelper { + protected SummaryHelper() { throw new IllegalStateException("Utility class"); } @@ -40,18 +39,6 @@ public static String arrayToString(List list, String delimiter) { return list.stream().map(T::toString).collect(Collectors.joining(String.format(delimiter))); } - public static String arrayToString( - List lineItems, - int[] columnSizes - ) { - return lineItems - .stream() - .map(T::toTableLine) - .collect( - Collectors.joining(String.format("%n%s%n ", SummaryHelper.lineSeparator(columnSizes, "-"))) - ); - } - /** * Truncates a string if it's too long for the requested width. */ diff --git a/src/main/java/com/mindee/parsing/standard/PositionData.java b/src/main/java/com/mindee/parsing/standard/PositionData.java deleted file mode 100644 index 347b73090..000000000 --- a/src/main/java/com/mindee/parsing/standard/PositionData.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.mindee.parsing.standard; - -import com.mindee.geometry.Polygon; - -/** - * A field with position data. - */ -public interface PositionData { - Polygon getBoundingBox(); - - Polygon getPolygon(); -} diff --git a/src/main/java/com/mindee/extraction/ExtractedPDF.java b/src/main/java/com/mindee/pdf/ExtractedPDF.java similarity index 97% rename from src/main/java/com/mindee/extraction/ExtractedPDF.java rename to src/main/java/com/mindee/pdf/ExtractedPDF.java index fdc859aec..3041ef143 100644 --- a/src/main/java/com/mindee/extraction/ExtractedPDF.java +++ b/src/main/java/com/mindee/pdf/ExtractedPDF.java @@ -1,4 +1,4 @@ -package com.mindee.extraction; +package com.mindee.pdf; import com.mindee.input.LocalInputSource; import java.io.ByteArrayOutputStream; diff --git a/src/main/java/com/mindee/extraction/PDFExtractor.java b/src/main/java/com/mindee/pdf/PDFExtractor.java similarity index 98% rename from src/main/java/com/mindee/extraction/PDFExtractor.java rename to src/main/java/com/mindee/pdf/PDFExtractor.java index 7f014ad8e..2b2323499 100644 --- a/src/main/java/com/mindee/extraction/PDFExtractor.java +++ b/src/main/java/com/mindee/pdf/PDFExtractor.java @@ -1,11 +1,11 @@ -package com.mindee.extraction; +package com.mindee.pdf; import static com.mindee.pdf.PDFUtils.mergePdfPages; import com.mindee.MindeeException; import com.mindee.input.InputSourceUtils; import com.mindee.input.LocalInputSource; -import com.mindee.product.invoicesplitter.InvoiceSplitterV1InvoicePageGroup; +import com.mindee.v1.product.invoicesplitter.InvoiceSplitterV1InvoicePageGroup; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/src/main/java/com/mindee/MindeeClient.java b/src/main/java/com/mindee/v1/MindeeClient.java similarity index 97% rename from src/main/java/com/mindee/MindeeClient.java rename to src/main/java/com/mindee/v1/MindeeClient.java index c4b96e093..7c401c04a 100644 --- a/src/main/java/com/mindee/MindeeClient.java +++ b/src/main/java/com/mindee/v1/MindeeClient.java @@ -1,23 +1,27 @@ -package com.mindee; +package com.mindee.v1; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.http.Endpoint; -import com.mindee.http.MindeeApi; -import com.mindee.http.MindeeHttpApi; -import com.mindee.http.RequestParameters; +import com.mindee.AsyncPollingOptions; +import com.mindee.MindeeException; import com.mindee.input.InputSourceUtils; import com.mindee.input.LocalInputSource; import com.mindee.input.LocalResponse; import com.mindee.input.PageOptions; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.parsing.common.Inference; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.common.WorkflowResponse; import com.mindee.pdf.PdfBoxApi; import com.mindee.pdf.PdfOperation; import com.mindee.pdf.SplitQuery; -import com.mindee.product.generated.GeneratedV1; +import com.mindee.v1.clientOptions.PredictOptions; +import com.mindee.v1.clientOptions.WorkflowOptions; +import com.mindee.v1.http.Endpoint; +import com.mindee.v1.http.MindeeApiV1; +import com.mindee.v1.http.MindeeHttpApiV1; +import com.mindee.v1.http.RequestParameters; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.Inference; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.WorkflowResponse; +import com.mindee.v1.product.generated.GeneratedV1; import java.io.IOException; import java.net.URL; @@ -27,7 +31,7 @@ public class MindeeClient { protected PdfOperation pdfOperation; - private final MindeeApi mindeeApi; + private final MindeeApiV1 mindeeApi; /** * Create a default MindeeClient. @@ -53,7 +57,7 @@ public MindeeClient(String apiKey) { * * @param mindeeApi The MindeeApi implementation to be used by the created MindeeClient. */ - public MindeeClient(MindeeApi mindeeApi) { + public MindeeClient(MindeeApiV1 mindeeApi) { this.pdfOperation = new PdfBoxApi(); this.mindeeApi = mindeeApi; } @@ -64,19 +68,19 @@ public MindeeClient(MindeeApi mindeeApi) { * @param pdfOperation The PdfOperation implementation to be used by the created MindeeClient. * @param mindeeApi The MindeeApi implementation to be used by the created MindeeClient. */ - public MindeeClient(PdfOperation pdfOperation, MindeeApi mindeeApi) { + public MindeeClient(PdfOperation pdfOperation, MindeeApiV1 mindeeApi) { this.pdfOperation = pdfOperation; this.mindeeApi = mindeeApi; } - private static MindeeApi createDefaultApi(String apiKey) { + private static MindeeApiV1 createDefaultApi(String apiKey) { MindeeSettings mindeeSettings; if (apiKey != null && !apiKey.trim().isEmpty()) { mindeeSettings = new MindeeSettings(apiKey); } else { mindeeSettings = new MindeeSettings(); } - return MindeeHttpApi.builder().mindeeSettings(mindeeSettings).build(); + return MindeeHttpApiV1.builder().mindeeSettings(mindeeSettings).build(); } /** diff --git a/src/main/java/com/mindee/MindeeSettings.java b/src/main/java/com/mindee/v1/MindeeSettings.java similarity index 98% rename from src/main/java/com/mindee/MindeeSettings.java rename to src/main/java/com/mindee/v1/MindeeSettings.java index 46af848b2..428c4aad8 100644 --- a/src/main/java/com/mindee/MindeeSettings.java +++ b/src/main/java/com/mindee/v1/MindeeSettings.java @@ -1,4 +1,4 @@ -package com.mindee; +package com.mindee.v1; import java.util.Optional; import lombok.Getter; diff --git a/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java b/src/main/java/com/mindee/v1/cli/CommandLineInterfaceProducts.java similarity index 88% rename from src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java rename to src/main/java/com/mindee/v1/cli/CommandLineInterfaceProducts.java index 813d1ff4e..3275e02f8 100644 --- a/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java +++ b/src/main/java/com/mindee/v1/cli/CommandLineInterfaceProducts.java @@ -1,19 +1,19 @@ -package com.mindee.cli; - -import com.mindee.product.barcodereader.BarcodeReaderV1; -import com.mindee.product.cropper.CropperV1; -import com.mindee.product.driverlicense.DriverLicenseV1; -import com.mindee.product.financialdocument.FinancialDocumentV1; -import com.mindee.product.fr.bankaccountdetails.BankAccountDetailsV2; -import com.mindee.product.fr.cartegrise.CarteGriseV1; -import com.mindee.product.fr.idcard.IdCardV2; -import com.mindee.product.ind.indianpassport.IndianPassportV1; -import com.mindee.product.internationalid.InternationalIdV2; -import com.mindee.product.invoice.InvoiceV4; -import com.mindee.product.invoicesplitter.InvoiceSplitterV1; -import com.mindee.product.multireceiptsdetector.MultiReceiptsDetectorV1; -import com.mindee.product.passport.PassportV1; -import com.mindee.product.receipt.ReceiptV5; +package com.mindee.v1.cli; + +import com.mindee.v1.product.barcodereader.BarcodeReaderV1; +import com.mindee.v1.product.cropper.CropperV1; +import com.mindee.v1.product.driverlicense.DriverLicenseV1; +import com.mindee.v1.product.financialdocument.FinancialDocumentV1; +import com.mindee.v1.product.fr.bankaccountdetails.BankAccountDetailsV2; +import com.mindee.v1.product.fr.cartegrise.CarteGriseV1; +import com.mindee.v1.product.fr.idcard.IdCardV2; +import com.mindee.v1.product.ind.indianpassport.IndianPassportV1; +import com.mindee.v1.product.internationalid.InternationalIdV2; +import com.mindee.v1.product.invoice.InvoiceV4; +import com.mindee.v1.product.invoicesplitter.InvoiceSplitterV1; +import com.mindee.v1.product.multireceiptsdetector.MultiReceiptsDetectorV1; +import com.mindee.v1.product.passport.PassportV1; +import com.mindee.v1.product.receipt.ReceiptV5; import java.io.File; import java.io.IOException; import picocli.CommandLine; diff --git a/src/main/java/com/mindee/cli/ProductProcessor.java b/src/main/java/com/mindee/v1/cli/ProductProcessor.java similarity index 94% rename from src/main/java/com/mindee/cli/ProductProcessor.java rename to src/main/java/com/mindee/v1/cli/ProductProcessor.java index 181ecf2ee..cdbecf9e3 100644 --- a/src/main/java/com/mindee/cli/ProductProcessor.java +++ b/src/main/java/com/mindee/v1/cli/ProductProcessor.java @@ -1,6 +1,6 @@ -package com.mindee.cli; +package com.mindee.v1.cli; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.parsing.common.Inference; import java.io.File; import java.io.IOException; import picocli.CommandLine; @@ -17,7 +17,7 @@ public interface ProductProcessor { /** * Process a product synchronously. - * + * * @param productClass Product class to be processed for synchronous products. * @param file Input file. * @param Type of the product. @@ -31,7 +31,7 @@ public interface ProductProcessor { /** * Process a product asynchronously. - * + * * @param productClass Product class to be processed for asynchronous products. * @param file Input file. * @param Type of the product. diff --git a/src/main/java/com/mindee/PredictOptions.java b/src/main/java/com/mindee/v1/clientOptions/PredictOptions.java similarity index 97% rename from src/main/java/com/mindee/PredictOptions.java rename to src/main/java/com/mindee/v1/clientOptions/PredictOptions.java index 40966adf4..ab2971705 100644 --- a/src/main/java/com/mindee/PredictOptions.java +++ b/src/main/java/com/mindee/v1/clientOptions/PredictOptions.java @@ -1,4 +1,4 @@ -package com.mindee; +package com.mindee.v1.clientOptions; import lombok.Builder; import lombok.Value; diff --git a/src/main/java/com/mindee/WorkflowOptions.java b/src/main/java/com/mindee/v1/clientOptions/WorkflowOptions.java similarity index 91% rename from src/main/java/com/mindee/WorkflowOptions.java rename to src/main/java/com/mindee/v1/clientOptions/WorkflowOptions.java index 2b5029adb..d3482cd66 100644 --- a/src/main/java/com/mindee/WorkflowOptions.java +++ b/src/main/java/com/mindee/v1/clientOptions/WorkflowOptions.java @@ -1,6 +1,6 @@ -package com.mindee; +package com.mindee.v1.clientOptions; -import com.mindee.parsing.common.ExecutionPriority; +import com.mindee.v1.parsing.common.ExecutionPriority; import lombok.Builder; import lombok.Value; diff --git a/src/main/java/com/mindee/http/CustomEndpointInfo.java b/src/main/java/com/mindee/v1/http/CustomEndpointInfo.java similarity index 96% rename from src/main/java/com/mindee/http/CustomEndpointInfo.java rename to src/main/java/com/mindee/v1/http/CustomEndpointInfo.java index a872a701f..4e207daed 100644 --- a/src/main/java/com/mindee/http/CustomEndpointInfo.java +++ b/src/main/java/com/mindee/v1/http/CustomEndpointInfo.java @@ -1,4 +1,4 @@ -package com.mindee.http; +package com.mindee.v1.http; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/src/main/java/com/mindee/http/Endpoint.java b/src/main/java/com/mindee/v1/http/Endpoint.java similarity index 95% rename from src/main/java/com/mindee/http/Endpoint.java rename to src/main/java/com/mindee/v1/http/Endpoint.java index 4b074203a..7aa1b9c19 100644 --- a/src/main/java/com/mindee/http/Endpoint.java +++ b/src/main/java/com/mindee/v1/http/Endpoint.java @@ -1,7 +1,7 @@ -package com.mindee.http; +package com.mindee.v1.http; import com.mindee.MindeeException; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/http/EndpointInfo.java b/src/main/java/com/mindee/v1/http/EndpointInfo.java similarity index 94% rename from src/main/java/com/mindee/http/EndpointInfo.java rename to src/main/java/com/mindee/v1/http/EndpointInfo.java index 08b30b874..b22becbf3 100644 --- a/src/main/java/com/mindee/http/EndpointInfo.java +++ b/src/main/java/com/mindee/v1/http/EndpointInfo.java @@ -1,4 +1,4 @@ -package com.mindee.http; +package com.mindee.v1.http; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/src/main/java/com/mindee/http/MindeeApi.java b/src/main/java/com/mindee/v1/http/MindeeApiV1.java similarity index 75% rename from src/main/java/com/mindee/http/MindeeApi.java rename to src/main/java/com/mindee/v1/http/MindeeApiV1.java index 19790da51..20cd77058 100644 --- a/src/main/java/com/mindee/http/MindeeApi.java +++ b/src/main/java/com/mindee/v1/http/MindeeApiV1.java @@ -1,15 +1,16 @@ -package com.mindee.http; +package com.mindee.v1.http; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.parsing.common.Inference; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.common.WorkflowResponse; +import com.mindee.http.MindeeApiCommon; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.Inference; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.WorkflowResponse; import java.io.IOException; /** * Defines required methods for an API. */ -public abstract class MindeeApi extends MindeeApiCommon { +public abstract class MindeeApiV1 extends MindeeApiCommon { /** * Get a document from the predict queue. diff --git a/src/main/java/com/mindee/http/MindeeHttpApi.java b/src/main/java/com/mindee/v1/http/MindeeHttpApiV1.java similarity index 95% rename from src/main/java/com/mindee/http/MindeeHttpApi.java rename to src/main/java/com/mindee/v1/http/MindeeHttpApiV1.java index 226d94a1e..76cfecd36 100644 --- a/src/main/java/com/mindee/http/MindeeHttpApi.java +++ b/src/main/java/com/mindee/v1/http/MindeeHttpApiV1.java @@ -1,17 +1,17 @@ -package com.mindee.http; +package com.mindee.v1.http; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; import com.mindee.MindeeException; -import com.mindee.MindeeSettings; -import com.mindee.parsing.common.ApiResponse; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.parsing.common.ErrorDetails; -import com.mindee.parsing.common.Inference; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.common.WorkflowResponse; +import com.mindee.v1.MindeeSettings; +import com.mindee.v1.parsing.common.ApiResponse; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.ErrorDetails; +import com.mindee.v1.parsing.common.Inference; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.WorkflowResponse; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; @@ -39,7 +39,7 @@ /** * HTTP Client class. */ -public final class MindeeHttpApi extends MindeeApi { +public final class MindeeHttpApiV1 extends MindeeApiV1 { private static final ObjectMapper mapper = JsonMapper.builder().findAndAddModules().build(); private final Function buildProductPredicBasetUrl = this::buildProductPredictBaseUrl; @@ -80,12 +80,12 @@ public final class MindeeHttpApi extends MindeeApi { */ private final Function workflowUrlFromId; - public MindeeHttpApi(MindeeSettings mindeeSettings) { + public MindeeHttpApiV1(MindeeSettings mindeeSettings) { this(mindeeSettings, null, null, null, null, null, null); } @Builder - private MindeeHttpApi( + private MindeeHttpApiV1( MindeeSettings mindeeSettings, HttpClientBuilder httpClientBuilder, Function urlFromEndpoint, @@ -171,7 +171,7 @@ public AsyncPredictResponse documentQueueGet( && mappedResponse.getJob().getError() != null && mappedResponse.getJob().getError().getCode() != null ) { - throw new MindeeHttpException( + throw new MindeeHttpExceptionV1( 500, mappedResponse.getJob().getError().getMessage(), mappedResponse.getJob().getError().getDetails().toString(), @@ -295,7 +295,7 @@ public WorkflowResponse executeWorkflowPost( } } - private MindeeHttpException getHttpError( + private MindeeHttpExceptionV1 getHttpError( JavaType parametricType, ClassicHttpResponse response ) { @@ -310,7 +310,7 @@ private MindeeHttpException getHttpError( message += "Could not read server response, check details."; errorCode = ""; details = err.getMessage(); - return new MindeeHttpException(statusCode, message, details, errorCode); + return new MindeeHttpExceptionV1(statusCode, message, details, errorCode); } try { ResponseT predictResponse = mapper.readValue(rawResponse, parametricType); @@ -327,7 +327,7 @@ private MindeeHttpException getHttpError( details = rawResponse; errorCode = ""; } - return new MindeeHttpException(statusCode, message, details, errorCode); + return new MindeeHttpExceptionV1(statusCode, message, details, errorCode); } private String buildProductPredictBaseUrl(Endpoint endpoint) { diff --git a/src/main/java/com/mindee/http/MindeeHttpException.java b/src/main/java/com/mindee/v1/http/MindeeHttpExceptionV1.java similarity index 76% rename from src/main/java/com/mindee/http/MindeeHttpException.java rename to src/main/java/com/mindee/v1/http/MindeeHttpExceptionV1.java index f774c4032..87ddacef4 100644 --- a/src/main/java/com/mindee/http/MindeeHttpException.java +++ b/src/main/java/com/mindee/v1/http/MindeeHttpExceptionV1.java @@ -1,4 +1,4 @@ -package com.mindee.http; +package com.mindee.v1.http; import com.mindee.MindeeException; import lombok.Getter; @@ -7,7 +7,7 @@ * Represent a Mindee exception. */ @Getter -public class MindeeHttpException extends MindeeException { +public class MindeeHttpExceptionV1 extends MindeeException { /** Standard HTTP status code. */ private final int statusCode; /** Error details. */ @@ -15,7 +15,7 @@ public class MindeeHttpException extends MindeeException { /** Error code (not HTTP code). */ private final String code; - public MindeeHttpException(int statusCode, String message, String details, String code) { + public MindeeHttpExceptionV1(int statusCode, String message, String details, String code) { super(message); this.statusCode = statusCode; this.details = details; diff --git a/src/main/java/com/mindee/http/RequestParameters.java b/src/main/java/com/mindee/v1/http/RequestParameters.java similarity index 88% rename from src/main/java/com/mindee/http/RequestParameters.java rename to src/main/java/com/mindee/v1/http/RequestParameters.java index c05dffd22..c227acd14 100644 --- a/src/main/java/com/mindee/http/RequestParameters.java +++ b/src/main/java/com/mindee/v1/http/RequestParameters.java @@ -1,7 +1,7 @@ -package com.mindee.http; +package com.mindee.v1.http; -import com.mindee.PredictOptions; -import com.mindee.WorkflowOptions; +import com.mindee.v1.clientOptions.PredictOptions; +import com.mindee.v1.clientOptions.WorkflowOptions; import java.net.URL; import lombok.Builder; import lombok.Value; diff --git a/src/main/java/com/mindee/v1/parsing/SummaryHelper.java b/src/main/java/com/mindee/v1/parsing/SummaryHelper.java new file mode 100644 index 000000000..81e4cbeff --- /dev/null +++ b/src/main/java/com/mindee/v1/parsing/SummaryHelper.java @@ -0,0 +1,22 @@ +package com.mindee.v1.parsing; + +import com.mindee.v1.parsing.standard.LineItemField; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Various static methods to help generate the prediction summaries. + */ +public final class SummaryHelper extends com.mindee.parsing.SummaryHelper { + public static String arrayToString( + List lineItems, + int[] columnSizes + ) { + return lineItems + .stream() + .map(T::toTableLine) + .collect( + Collectors.joining(String.format("%n%s%n ", SummaryHelper.lineSeparator(columnSizes, "-"))) + ); + } +} diff --git a/src/main/java/com/mindee/parsing/common/ApiRequest.java b/src/main/java/com/mindee/v1/parsing/common/ApiRequest.java similarity index 96% rename from src/main/java/com/mindee/parsing/common/ApiRequest.java rename to src/main/java/com/mindee/v1/parsing/common/ApiRequest.java index 7b4bb8e09..709c10b51 100644 --- a/src/main/java/com/mindee/parsing/common/ApiRequest.java +++ b/src/main/java/com/mindee/v1/parsing/common/ApiRequest.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/ApiResponse.java b/src/main/java/com/mindee/v1/parsing/common/ApiResponse.java similarity index 94% rename from src/main/java/com/mindee/parsing/common/ApiResponse.java rename to src/main/java/com/mindee/v1/parsing/common/ApiResponse.java index 860073259..1162d9944 100644 --- a/src/main/java/com/mindee/parsing/common/ApiResponse.java +++ b/src/main/java/com/mindee/v1/parsing/common/ApiResponse.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/AsyncPredictResponse.java b/src/main/java/com/mindee/v1/parsing/common/AsyncPredictResponse.java similarity index 97% rename from src/main/java/com/mindee/parsing/common/AsyncPredictResponse.java rename to src/main/java/com/mindee/v1/parsing/common/AsyncPredictResponse.java index 64847f2ed..9066f574a 100644 --- a/src/main/java/com/mindee/parsing/common/AsyncPredictResponse.java +++ b/src/main/java/com/mindee/v1/parsing/common/AsyncPredictResponse.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/Cropper.java b/src/main/java/com/mindee/v1/parsing/common/Cropper.java similarity index 82% rename from src/main/java/com/mindee/parsing/common/Cropper.java rename to src/main/java/com/mindee/v1/parsing/common/Cropper.java index 1e7d70204..2e30576a9 100644 --- a/src/main/java/com/mindee/parsing/common/Cropper.java +++ b/src/main/java/com/mindee/v1/parsing/common/Cropper.java @@ -1,8 +1,8 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.standard.PositionField; +import com.mindee.v1.parsing.standard.PositionField; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/parsing/common/Document.java b/src/main/java/com/mindee/v1/parsing/common/Document.java similarity index 93% rename from src/main/java/com/mindee/parsing/common/Document.java rename to src/main/java/com/mindee/v1/parsing/common/Document.java index 6d68f2d36..a506766c1 100644 --- a/src/main/java/com/mindee/parsing/common/Document.java +++ b/src/main/java/com/mindee/v1/parsing/common/Document.java @@ -1,8 +1,8 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.common.ocr.Ocr; +import com.mindee.v1.parsing.common.ocr.Ocr; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/parsing/common/Error.java b/src/main/java/com/mindee/v1/parsing/common/Error.java similarity index 95% rename from src/main/java/com/mindee/parsing/common/Error.java rename to src/main/java/com/mindee/v1/parsing/common/Error.java index e92a65f2a..6eafbba9f 100644 --- a/src/main/java/com/mindee/parsing/common/Error.java +++ b/src/main/java/com/mindee/v1/parsing/common/Error.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/ErrorDetails.java b/src/main/java/com/mindee/v1/parsing/common/ErrorDetails.java similarity index 93% rename from src/main/java/com/mindee/parsing/common/ErrorDetails.java rename to src/main/java/com/mindee/v1/parsing/common/ErrorDetails.java index c7eb87b2d..970636b63 100644 --- a/src/main/java/com/mindee/parsing/common/ErrorDetails.java +++ b/src/main/java/com/mindee/v1/parsing/common/ErrorDetails.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; diff --git a/src/main/java/com/mindee/parsing/common/ErrorDetailsDeserializer.java b/src/main/java/com/mindee/v1/parsing/common/ErrorDetailsDeserializer.java similarity index 96% rename from src/main/java/com/mindee/parsing/common/ErrorDetailsDeserializer.java rename to src/main/java/com/mindee/v1/parsing/common/ErrorDetailsDeserializer.java index c45bfc7d2..14033d822 100644 --- a/src/main/java/com/mindee/parsing/common/ErrorDetailsDeserializer.java +++ b/src/main/java/com/mindee/v1/parsing/common/ErrorDetailsDeserializer.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; diff --git a/src/main/java/com/mindee/parsing/common/Execution.java b/src/main/java/com/mindee/v1/parsing/common/Execution.java similarity index 96% rename from src/main/java/com/mindee/parsing/common/Execution.java rename to src/main/java/com/mindee/v1/parsing/common/Execution.java index 575071b5f..9c1221c97 100644 --- a/src/main/java/com/mindee/parsing/common/Execution.java +++ b/src/main/java/com/mindee/v1/parsing/common/Execution.java @@ -1,9 +1,9 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.product.generated.GeneratedV1Document; +import com.mindee.v1.product.generated.GeneratedV1Document; import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/parsing/common/ExecutionFile.java b/src/main/java/com/mindee/v1/parsing/common/ExecutionFile.java similarity index 95% rename from src/main/java/com/mindee/parsing/common/ExecutionFile.java rename to src/main/java/com/mindee/v1/parsing/common/ExecutionFile.java index c2dd23c89..24f8f9b07 100644 --- a/src/main/java/com/mindee/parsing/common/ExecutionFile.java +++ b/src/main/java/com/mindee/v1/parsing/common/ExecutionFile.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/ExecutionPriority.java b/src/main/java/com/mindee/v1/parsing/common/ExecutionPriority.java similarity index 90% rename from src/main/java/com/mindee/parsing/common/ExecutionPriority.java rename to src/main/java/com/mindee/v1/parsing/common/ExecutionPriority.java index 845300cdf..b9e048d7e 100644 --- a/src/main/java/com/mindee/parsing/common/ExecutionPriority.java +++ b/src/main/java/com/mindee/v1/parsing/common/ExecutionPriority.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/src/main/java/com/mindee/parsing/common/Extras.java b/src/main/java/com/mindee/v1/parsing/common/Extras.java similarity index 93% rename from src/main/java/com/mindee/parsing/common/Extras.java rename to src/main/java/com/mindee/v1/parsing/common/Extras.java index 70b332503..05064a283 100644 --- a/src/main/java/com/mindee/parsing/common/Extras.java +++ b/src/main/java/com/mindee/v1/parsing/common/Extras.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/FullTextOcr.java b/src/main/java/com/mindee/v1/parsing/common/FullTextOcr.java similarity index 93% rename from src/main/java/com/mindee/parsing/common/FullTextOcr.java rename to src/main/java/com/mindee/v1/parsing/common/FullTextOcr.java index 65754e149..d8f811a37 100644 --- a/src/main/java/com/mindee/parsing/common/FullTextOcr.java +++ b/src/main/java/com/mindee/v1/parsing/common/FullTextOcr.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/Inference.java b/src/main/java/com/mindee/v1/parsing/common/Inference.java similarity index 96% rename from src/main/java/com/mindee/parsing/common/Inference.java rename to src/main/java/com/mindee/v1/parsing/common/Inference.java index f91fcd041..c222017fe 100644 --- a/src/main/java/com/mindee/parsing/common/Inference.java +++ b/src/main/java/com/mindee/v1/parsing/common/Inference.java @@ -1,8 +1,8 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; +import com.mindee.v1.parsing.SummaryHelper; import java.util.stream.Collectors; import lombok.Getter; diff --git a/src/main/java/com/mindee/parsing/common/InferenceExtras.java b/src/main/java/com/mindee/v1/parsing/common/InferenceExtras.java similarity index 93% rename from src/main/java/com/mindee/parsing/common/InferenceExtras.java rename to src/main/java/com/mindee/v1/parsing/common/InferenceExtras.java index a8f065960..f7af1b231 100644 --- a/src/main/java/com/mindee/parsing/common/InferenceExtras.java +++ b/src/main/java/com/mindee/v1/parsing/common/InferenceExtras.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/Job.java b/src/main/java/com/mindee/v1/parsing/common/Job.java similarity index 96% rename from src/main/java/com/mindee/parsing/common/Job.java rename to src/main/java/com/mindee/v1/parsing/common/Job.java index b8b886882..80d44f524 100644 --- a/src/main/java/com/mindee/parsing/common/Job.java +++ b/src/main/java/com/mindee/v1/parsing/common/Job.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/LocalDateTimeDeserializer.java b/src/main/java/com/mindee/v1/parsing/common/LocalDateTimeDeserializer.java similarity index 97% rename from src/main/java/com/mindee/parsing/common/LocalDateTimeDeserializer.java rename to src/main/java/com/mindee/v1/parsing/common/LocalDateTimeDeserializer.java index 33fa5e8f5..464744318 100644 --- a/src/main/java/com/mindee/parsing/common/LocalDateTimeDeserializer.java +++ b/src/main/java/com/mindee/v1/parsing/common/LocalDateTimeDeserializer.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; diff --git a/src/main/java/com/mindee/parsing/common/Orientation.java b/src/main/java/com/mindee/v1/parsing/common/Orientation.java similarity index 91% rename from src/main/java/com/mindee/parsing/common/Orientation.java rename to src/main/java/com/mindee/v1/parsing/common/Orientation.java index 3f02a85e3..1b9a05a77 100644 --- a/src/main/java/com/mindee/parsing/common/Orientation.java +++ b/src/main/java/com/mindee/v1/parsing/common/Orientation.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/Page.java b/src/main/java/com/mindee/v1/parsing/common/Page.java similarity index 98% rename from src/main/java/com/mindee/parsing/common/Page.java rename to src/main/java/com/mindee/v1/parsing/common/Page.java index 070c00900..b8df27197 100644 --- a/src/main/java/com/mindee/parsing/common/Page.java +++ b/src/main/java/com/mindee/v1/parsing/common/Page.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/Pages.java b/src/main/java/com/mindee/v1/parsing/common/Pages.java similarity index 92% rename from src/main/java/com/mindee/parsing/common/Pages.java rename to src/main/java/com/mindee/v1/parsing/common/Pages.java index ae4b002fb..039919c68 100644 --- a/src/main/java/com/mindee/parsing/common/Pages.java +++ b/src/main/java/com/mindee/v1/parsing/common/Pages.java @@ -1,11 +1,11 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import java.util.ArrayList; import java.util.stream.Collectors; /** * List of all pages in the inference. - * + * * @param */ public class Pages extends ArrayList> { diff --git a/src/main/java/com/mindee/parsing/common/PredictResponse.java b/src/main/java/com/mindee/v1/parsing/common/PredictResponse.java similarity index 95% rename from src/main/java/com/mindee/parsing/common/PredictResponse.java rename to src/main/java/com/mindee/v1/parsing/common/PredictResponse.java index ad6c9f782..98b1a4fdb 100644 --- a/src/main/java/com/mindee/parsing/common/PredictResponse.java +++ b/src/main/java/com/mindee/v1/parsing/common/PredictResponse.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/Prediction.java b/src/main/java/com/mindee/v1/parsing/common/Prediction.java similarity index 89% rename from src/main/java/com/mindee/parsing/common/Prediction.java rename to src/main/java/com/mindee/v1/parsing/common/Prediction.java index 54dd812ac..589b4c092 100644 --- a/src/main/java/com/mindee/parsing/common/Prediction.java +++ b/src/main/java/com/mindee/v1/parsing/common/Prediction.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; /** * Base class for all predictions. diff --git a/src/main/java/com/mindee/parsing/common/Product.java b/src/main/java/com/mindee/v1/parsing/common/Product.java similarity index 92% rename from src/main/java/com/mindee/parsing/common/Product.java rename to src/main/java/com/mindee/v1/parsing/common/Product.java index c7c7ce01d..b3fca989e 100644 --- a/src/main/java/com/mindee/parsing/common/Product.java +++ b/src/main/java/com/mindee/v1/parsing/common/Product.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/Rag.java b/src/main/java/com/mindee/v1/parsing/common/Rag.java similarity index 92% rename from src/main/java/com/mindee/parsing/common/Rag.java rename to src/main/java/com/mindee/v1/parsing/common/Rag.java index ca124b5a7..a208b84a6 100644 --- a/src/main/java/com/mindee/parsing/common/Rag.java +++ b/src/main/java/com/mindee/v1/parsing/common/Rag.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/WorkflowResponse.java b/src/main/java/com/mindee/v1/parsing/common/WorkflowResponse.java similarity index 89% rename from src/main/java/com/mindee/parsing/common/WorkflowResponse.java rename to src/main/java/com/mindee/v1/parsing/common/WorkflowResponse.java index 439905c26..30db30be9 100644 --- a/src/main/java/com/mindee/parsing/common/WorkflowResponse.java +++ b/src/main/java/com/mindee/v1/parsing/common/WorkflowResponse.java @@ -1,8 +1,8 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.product.generated.GeneratedV1; +import com.mindee.v1.product.generated.GeneratedV1; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/parsing/common/ocr/MvisionV1.java b/src/main/java/com/mindee/v1/parsing/common/ocr/MvisionV1.java similarity index 93% rename from src/main/java/com/mindee/parsing/common/ocr/MvisionV1.java rename to src/main/java/com/mindee/v1/parsing/common/ocr/MvisionV1.java index c27622f4f..e86d35ba7 100644 --- a/src/main/java/com/mindee/parsing/common/ocr/MvisionV1.java +++ b/src/main/java/com/mindee/v1/parsing/common/ocr/MvisionV1.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common.ocr; +package com.mindee.v1.parsing.common.ocr; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/ocr/Ocr.java b/src/main/java/com/mindee/v1/parsing/common/ocr/Ocr.java similarity index 90% rename from src/main/java/com/mindee/parsing/common/ocr/Ocr.java rename to src/main/java/com/mindee/v1/parsing/common/ocr/Ocr.java index 8516eb8e4..b1ef36f20 100644 --- a/src/main/java/com/mindee/parsing/common/ocr/Ocr.java +++ b/src/main/java/com/mindee/v1/parsing/common/ocr/Ocr.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common.ocr; +package com.mindee.v1.parsing.common.ocr; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/common/ocr/OcrPage.java b/src/main/java/com/mindee/v1/parsing/common/ocr/OcrPage.java similarity index 91% rename from src/main/java/com/mindee/parsing/common/ocr/OcrPage.java rename to src/main/java/com/mindee/v1/parsing/common/ocr/OcrPage.java index ce283e566..af2cbd473 100644 --- a/src/main/java/com/mindee/parsing/common/ocr/OcrPage.java +++ b/src/main/java/com/mindee/v1/parsing/common/ocr/OcrPage.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common.ocr; +package com.mindee.v1.parsing.common.ocr; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -28,8 +28,7 @@ public OcrPage(@JsonProperty("all_words") List allWords) { this.allWords = allWords; // make sure words are sorted from top to bottom - this.allWords - .sort((word1, word2) -> PolygonUtils.CompareOnY(word1.getPolygon(), word2.getPolygon())); + this.allWords.sort((word1, word2) -> word1.getPolygon().compareOnY(word2.getPolygon())); } /** @@ -74,8 +73,7 @@ protected List> toLines() { } current = null; if (!line.isEmpty()) { - line - .sort((word1, word2) -> PolygonUtils.CompareOnX(word1.getPolygon(), word2.getPolygon())); + line.sort((word1, word2) -> word1.getPolygon().compareOnX(word2.getPolygon())); lines.add(line); } } diff --git a/src/main/java/com/mindee/parsing/common/ocr/Word.java b/src/main/java/com/mindee/v1/parsing/common/ocr/Word.java similarity index 94% rename from src/main/java/com/mindee/parsing/common/ocr/Word.java rename to src/main/java/com/mindee/v1/parsing/common/ocr/Word.java index 8d574b2cf..621abc03f 100644 --- a/src/main/java/com/mindee/parsing/common/ocr/Word.java +++ b/src/main/java/com/mindee/v1/parsing/common/ocr/Word.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common.ocr; +package com.mindee.v1.parsing.common.ocr; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/generated/GeneratedFeature.java b/src/main/java/com/mindee/v1/parsing/generated/GeneratedFeature.java similarity index 89% rename from src/main/java/com/mindee/parsing/generated/GeneratedFeature.java rename to src/main/java/com/mindee/v1/parsing/generated/GeneratedFeature.java index 7c0d37f36..365f477ea 100644 --- a/src/main/java/com/mindee/parsing/generated/GeneratedFeature.java +++ b/src/main/java/com/mindee/v1/parsing/generated/GeneratedFeature.java @@ -1,11 +1,11 @@ -package com.mindee.parsing.generated; +package com.mindee.v1.parsing.generated; import com.mindee.MindeeException; -import com.mindee.parsing.standard.AmountField; -import com.mindee.parsing.standard.BooleanField; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.standard.AmountField; +import com.mindee.v1.parsing.standard.BooleanField; +import com.mindee.v1.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.StringField; import java.util.ArrayList; import lombok.Getter; @@ -35,7 +35,7 @@ public class GeneratedFeature extends ArrayList { /** * Whether the original feature is a list. - * + * * @param isList Whether the feature is a list. */ public GeneratedFeature(boolean isList) { @@ -45,7 +45,7 @@ public GeneratedFeature(boolean isList) { /** * Represent the feature as a standard {@link StringField}. * Only works for non-list features. - * + * * @return An instance of a {@link StringField}. */ public StringField asStringField() { @@ -57,7 +57,7 @@ public StringField asStringField() { /** * Represent the feature as a standard {@link BooleanField}. - * + * * @return An instance of a {@link BooleanField}. */ public BooleanField asBooleanField() { @@ -70,7 +70,7 @@ public BooleanField asBooleanField() { /** * Represent the feature as a standard {@link AmountField}. * Only works for non-list features. - * + * * @return An instance of a {@link AmountField}. */ public AmountField asAmountField() { @@ -83,7 +83,7 @@ public AmountField asAmountField() { /** * Represent the feature as a standard {@link DateField}. * Only works for non-list features. - * + * * @return An instance of a {@link DateField}. */ public DateField asDateField() { @@ -96,7 +96,7 @@ public DateField asDateField() { /** * Represent the feature as a standard {@link ClassificationField}. * Only works for non-list features. - * + * * @return An instance of a {@link ClassificationField}. */ public ClassificationField asClassificationField() { diff --git a/src/main/java/com/mindee/parsing/generated/GeneratedObject.java b/src/main/java/com/mindee/v1/parsing/generated/GeneratedObject.java similarity index 89% rename from src/main/java/com/mindee/parsing/generated/GeneratedObject.java rename to src/main/java/com/mindee/v1/parsing/generated/GeneratedObject.java index 130669a87..ce1c883f0 100644 --- a/src/main/java/com/mindee/parsing/generated/GeneratedObject.java +++ b/src/main/java/com/mindee/v1/parsing/generated/GeneratedObject.java @@ -1,12 +1,11 @@ -package com.mindee.parsing.generated; +package com.mindee.v1.parsing.generated; import com.mindee.geometry.Polygon; -import com.mindee.geometry.PolygonUtils; -import com.mindee.parsing.standard.AmountField; -import com.mindee.parsing.standard.BooleanField; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.standard.AmountField; +import com.mindee.v1.parsing.standard.BooleanField; +import com.mindee.v1.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.StringField; import java.time.LocalDate; import java.util.HashMap; import java.util.List; @@ -18,7 +17,7 @@ public class GeneratedObject extends HashMap { /** * Represent the object as a standard {@link StringField}. - * + * * @return A {@link StringField} containing a string value. */ public StringField asStringField() { @@ -33,7 +32,7 @@ public StringField asStringField() { /** * Represent the object as a standard {@link AmountField}. - * + * * @return An {@link AmountField} containing a double value. */ public AmountField asAmountField() { @@ -51,7 +50,7 @@ public AmountField asAmountField() { /** * Represent the object as a standard {@link BooleanField}. - * + * * @return A {@link BooleanField} containing a boolean value. */ public BooleanField asBooleanField() { @@ -69,7 +68,7 @@ public BooleanField asBooleanField() { /** * Represent the object as a standard {@link DateField}. - * + * * @return A {@link DateField} containing a date value. */ public DateField asDateField() { @@ -84,7 +83,7 @@ public DateField asDateField() { /** * Represent the object as a standard {@link ClassificationField}. - * + * * @return A {@link ClassificationField} containing a string value. */ public ClassificationField asClassificationField() { @@ -93,7 +92,7 @@ public ClassificationField asClassificationField() { /** * Get the polygon, if present. - * + * * @return A {@link Polygon}. */ public Polygon getPolygon() { @@ -102,7 +101,7 @@ public Polygon getPolygon() { /** * Get the specified key as a {@link Polygon} object. - * + * * @param key Key to retrieve the polygon from. * @return A {@link Polygon}. */ @@ -126,12 +125,12 @@ public Polygon getAsPolygon(String key) { } } } - return PolygonUtils.getFrom((List>) rawPolygon); + return new Polygon((List>) rawPolygon); } /** * Get the page ID, if present. - * + * * @return A page ID, as an integer. */ public Integer getPageId() { @@ -140,7 +139,7 @@ public Integer getPageId() { /** * Get the confidence score, if present. - * + * * @return The confidence score, as a double. */ public Double getConfidence() { @@ -149,7 +148,7 @@ public Double getConfidence() { /** * Get the information on whether the date field was extracted. - * + * * @return A boolean representation of the field. */ public Boolean getIsComputed() { diff --git a/src/main/java/com/mindee/parsing/generated/GeneratedV1PredictionDeserializer.java b/src/main/java/com/mindee/v1/parsing/generated/GeneratedV1PredictionDeserializer.java similarity index 95% rename from src/main/java/com/mindee/parsing/generated/GeneratedV1PredictionDeserializer.java rename to src/main/java/com/mindee/v1/parsing/generated/GeneratedV1PredictionDeserializer.java index 626f0d480..8369810ac 100644 --- a/src/main/java/com/mindee/parsing/generated/GeneratedV1PredictionDeserializer.java +++ b/src/main/java/com/mindee/v1/parsing/generated/GeneratedV1PredictionDeserializer.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.generated; +package com.mindee.v1.parsing.generated; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.type.TypeReference; @@ -7,7 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.mindee.product.generated.GeneratedV1Document; +import com.mindee.v1.product.generated.GeneratedV1Document; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; diff --git a/src/main/java/com/mindee/parsing/standard/AddressField.java b/src/main/java/com/mindee/v1/parsing/standard/AddressField.java similarity index 98% rename from src/main/java/com/mindee/parsing/standard/AddressField.java rename to src/main/java/com/mindee/v1/parsing/standard/AddressField.java index faeea5303..ef1f2094f 100644 --- a/src/main/java/com/mindee/parsing/standard/AddressField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/AddressField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/standard/AmountField.java b/src/main/java/com/mindee/v1/parsing/standard/AmountField.java similarity index 92% rename from src/main/java/com/mindee/parsing/standard/AmountField.java rename to src/main/java/com/mindee/v1/parsing/standard/AmountField.java index 8ec6af2db..41d425259 100644 --- a/src/main/java/com/mindee/parsing/standard/AmountField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/AmountField.java @@ -1,11 +1,11 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.mindee.geometry.Polygon; import com.mindee.geometry.PolygonDeserializer; -import com.mindee.parsing.SummaryHelper; +import com.mindee.v1.parsing.SummaryHelper; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/parsing/standard/BaseField.java b/src/main/java/com/mindee/v1/parsing/standard/BaseField.java similarity index 93% rename from src/main/java/com/mindee/parsing/standard/BaseField.java rename to src/main/java/com/mindee/v1/parsing/standard/BaseField.java index d085e40d0..f4fa24f0c 100644 --- a/src/main/java/com/mindee/parsing/standard/BaseField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/BaseField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -7,6 +7,7 @@ import com.mindee.geometry.BoundingBoxUtils; import com.mindee.geometry.Polygon; import com.mindee.geometry.PolygonDeserializer; +import com.mindee.geometry.PositionDataField; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,7 +17,7 @@ @Getter @EqualsAndHashCode @JsonIgnoreProperties(ignoreUnknown = true) -public abstract class BaseField implements PositionData { +public abstract class BaseField implements PositionDataField { /** * The bounding box equivalent of the polygon. diff --git a/src/main/java/com/mindee/parsing/standard/BooleanField.java b/src/main/java/com/mindee/v1/parsing/standard/BooleanField.java similarity index 92% rename from src/main/java/com/mindee/parsing/standard/BooleanField.java rename to src/main/java/com/mindee/v1/parsing/standard/BooleanField.java index 88a02c796..d3d5e4b5d 100644 --- a/src/main/java/com/mindee/parsing/standard/BooleanField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/BooleanField.java @@ -1,11 +1,11 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.mindee.geometry.Polygon; import com.mindee.geometry.PolygonDeserializer; -import com.mindee.parsing.SummaryHelper; +import com.mindee.v1.parsing.SummaryHelper; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/parsing/standard/ClassificationField.java b/src/main/java/com/mindee/v1/parsing/standard/ClassificationField.java similarity index 93% rename from src/main/java/com/mindee/parsing/standard/ClassificationField.java rename to src/main/java/com/mindee/v1/parsing/standard/ClassificationField.java index 326e4856f..7a26b74dc 100644 --- a/src/main/java/com/mindee/parsing/standard/ClassificationField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/ClassificationField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/standard/CompanyRegistrationField.java b/src/main/java/com/mindee/v1/parsing/standard/CompanyRegistrationField.java similarity index 95% rename from src/main/java/com/mindee/parsing/standard/CompanyRegistrationField.java rename to src/main/java/com/mindee/v1/parsing/standard/CompanyRegistrationField.java index 5596b4e76..6018468d7 100644 --- a/src/main/java/com/mindee/parsing/standard/CompanyRegistrationField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/CompanyRegistrationField.java @@ -1,8 +1,8 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; +import com.mindee.v1.parsing.SummaryHelper; import java.util.HashMap; import java.util.Map; import lombok.Getter; diff --git a/src/main/java/com/mindee/parsing/standard/DateField.java b/src/main/java/com/mindee/v1/parsing/standard/DateField.java similarity index 97% rename from src/main/java/com/mindee/parsing/standard/DateField.java rename to src/main/java/com/mindee/v1/parsing/standard/DateField.java index 0f2aa7b98..9699bd6e3 100644 --- a/src/main/java/com/mindee/parsing/standard/DateField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/DateField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/standard/LineItemField.java b/src/main/java/com/mindee/v1/parsing/standard/LineItemField.java similarity index 76% rename from src/main/java/com/mindee/parsing/standard/LineItemField.java rename to src/main/java/com/mindee/v1/parsing/standard/LineItemField.java index 151e3c9d3..c75eb4f25 100644 --- a/src/main/java/com/mindee/parsing/standard/LineItemField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/LineItemField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; /** * Represent a single line in a field printable as an rST table. diff --git a/src/main/java/com/mindee/parsing/standard/LocaleField.java b/src/main/java/com/mindee/v1/parsing/standard/LocaleField.java similarity index 98% rename from src/main/java/com/mindee/parsing/standard/LocaleField.java rename to src/main/java/com/mindee/v1/parsing/standard/LocaleField.java index 47fe88cfa..e763fb0b3 100644 --- a/src/main/java/com/mindee/parsing/standard/LocaleField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/LocaleField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/standard/PaymentDetailsField.java b/src/main/java/com/mindee/v1/parsing/standard/PaymentDetailsField.java similarity index 97% rename from src/main/java/com/mindee/parsing/standard/PaymentDetailsField.java rename to src/main/java/com/mindee/v1/parsing/standard/PaymentDetailsField.java index 935a02d53..6cd7b5012 100644 --- a/src/main/java/com/mindee/parsing/standard/PaymentDetailsField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/PaymentDetailsField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/standard/PositionField.java b/src/main/java/com/mindee/v1/parsing/standard/PositionField.java similarity index 91% rename from src/main/java/com/mindee/parsing/standard/PositionField.java rename to src/main/java/com/mindee/v1/parsing/standard/PositionField.java index 89848593a..dbbe85ea7 100644 --- a/src/main/java/com/mindee/parsing/standard/PositionField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/PositionField.java @@ -1,10 +1,11 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.mindee.geometry.Polygon; import com.mindee.geometry.PolygonDeserializer; +import com.mindee.geometry.PositionDataField; import lombok.Getter; /** @@ -12,7 +13,7 @@ */ @Getter @JsonIgnoreProperties(ignoreUnknown = true) -public class PositionField implements PositionData { +public class PositionField implements PositionDataField { /** * Straight rectangle. diff --git a/src/main/java/com/mindee/parsing/standard/StringField.java b/src/main/java/com/mindee/v1/parsing/standard/StringField.java similarity index 93% rename from src/main/java/com/mindee/parsing/standard/StringField.java rename to src/main/java/com/mindee/v1/parsing/standard/StringField.java index 67c869125..cd4982c04 100644 --- a/src/main/java/com/mindee/parsing/standard/StringField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/StringField.java @@ -1,11 +1,11 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.mindee.geometry.Polygon; import com.mindee.geometry.PolygonDeserializer; -import com.mindee.parsing.SummaryHelper; +import com.mindee.v1.parsing.SummaryHelper; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/parsing/standard/TaxField.java b/src/main/java/com/mindee/v1/parsing/standard/TaxField.java similarity index 96% rename from src/main/java/com/mindee/parsing/standard/TaxField.java rename to src/main/java/com/mindee/v1/parsing/standard/TaxField.java index 50a961fb9..1bd7fa244 100644 --- a/src/main/java/com/mindee/parsing/standard/TaxField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/TaxField.java @@ -1,8 +1,8 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; +import com.mindee.v1.parsing.SummaryHelper; import java.util.HashMap; import java.util.Map; import lombok.Getter; diff --git a/src/main/java/com/mindee/parsing/standard/Taxes.java b/src/main/java/com/mindee/v1/parsing/standard/Taxes.java similarity index 88% rename from src/main/java/com/mindee/parsing/standard/Taxes.java rename to src/main/java/com/mindee/v1/parsing/standard/Taxes.java index 49cdce126..d4b72dd89 100644 --- a/src/main/java/com/mindee/parsing/standard/Taxes.java +++ b/src/main/java/com/mindee/v1/parsing/standard/Taxes.java @@ -1,6 +1,6 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; -import com.mindee.parsing.SummaryHelper; +import com.mindee.v1.parsing.SummaryHelper; import java.util.ArrayList; /** diff --git a/src/main/java/com/mindee/parsing/standard/TaxesDeserializer.java b/src/main/java/com/mindee/v1/parsing/standard/TaxesDeserializer.java similarity index 96% rename from src/main/java/com/mindee/parsing/standard/TaxesDeserializer.java rename to src/main/java/com/mindee/v1/parsing/standard/TaxesDeserializer.java index a98e6a720..b73c4abab 100644 --- a/src/main/java/com/mindee/parsing/standard/TaxesDeserializer.java +++ b/src/main/java/com/mindee/v1/parsing/standard/TaxesDeserializer.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/src/main/java/com/mindee/product/barcodereader/BarcodeReaderV1.java b/src/main/java/com/mindee/v1/product/barcodereader/BarcodeReaderV1.java similarity index 73% rename from src/main/java/com/mindee/product/barcodereader/BarcodeReaderV1.java rename to src/main/java/com/mindee/v1/product/barcodereader/BarcodeReaderV1.java index 8e8dad7aa..9e90aaf86 100644 --- a/src/main/java/com/mindee/product/barcodereader/BarcodeReaderV1.java +++ b/src/main/java/com/mindee/v1/product/barcodereader/BarcodeReaderV1.java @@ -1,8 +1,8 @@ -package com.mindee.product.barcodereader; +package com.mindee.v1.product.barcodereader; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/barcodereader/BarcodeReaderV1Document.java b/src/main/java/com/mindee/v1/product/barcodereader/BarcodeReaderV1Document.java similarity index 87% rename from src/main/java/com/mindee/product/barcodereader/BarcodeReaderV1Document.java rename to src/main/java/com/mindee/v1/product/barcodereader/BarcodeReaderV1Document.java index fe6c44267..ac3d9e546 100644 --- a/src/main/java/com/mindee/product/barcodereader/BarcodeReaderV1Document.java +++ b/src/main/java/com/mindee/v1/product/barcodereader/BarcodeReaderV1Document.java @@ -1,10 +1,10 @@ -package com.mindee.product.barcodereader; +package com.mindee.v1.product.barcodereader; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.StringField; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/cropper/CropperV1.java b/src/main/java/com/mindee/v1/product/cropper/CropperV1.java similarity index 72% rename from src/main/java/com/mindee/product/cropper/CropperV1.java rename to src/main/java/com/mindee/v1/product/cropper/CropperV1.java index 031f76627..2210a5f8a 100644 --- a/src/main/java/com/mindee/product/cropper/CropperV1.java +++ b/src/main/java/com/mindee/v1/product/cropper/CropperV1.java @@ -1,8 +1,8 @@ -package com.mindee.product.cropper; +package com.mindee.v1.product.cropper; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/cropper/CropperV1Document.java b/src/main/java/com/mindee/v1/product/cropper/CropperV1Document.java similarity index 83% rename from src/main/java/com/mindee/product/cropper/CropperV1Document.java rename to src/main/java/com/mindee/v1/product/cropper/CropperV1Document.java index e2fa77603..7ffacad26 100644 --- a/src/main/java/com/mindee/product/cropper/CropperV1Document.java +++ b/src/main/java/com/mindee/v1/product/cropper/CropperV1Document.java @@ -1,7 +1,7 @@ -package com.mindee.product.cropper; +package com.mindee.v1.product.cropper; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.parsing.common.Prediction; +import com.mindee.v1.parsing.common.Prediction; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/cropper/CropperV1Page.java b/src/main/java/com/mindee/v1/product/cropper/CropperV1Page.java similarity index 88% rename from src/main/java/com/mindee/product/cropper/CropperV1Page.java rename to src/main/java/com/mindee/v1/product/cropper/CropperV1Page.java index 31a29cec0..48aaf4c69 100644 --- a/src/main/java/com/mindee/product/cropper/CropperV1Page.java +++ b/src/main/java/com/mindee/v1/product/cropper/CropperV1Page.java @@ -1,9 +1,9 @@ -package com.mindee.product.cropper; +package com.mindee.v1.product.cropper; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.PositionField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.standard.PositionField; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/driverlicense/DriverLicenseV1.java b/src/main/java/com/mindee/v1/product/driverlicense/DriverLicenseV1.java similarity index 73% rename from src/main/java/com/mindee/product/driverlicense/DriverLicenseV1.java rename to src/main/java/com/mindee/v1/product/driverlicense/DriverLicenseV1.java index 5035f64b0..1c27f8f47 100644 --- a/src/main/java/com/mindee/product/driverlicense/DriverLicenseV1.java +++ b/src/main/java/com/mindee/v1/product/driverlicense/DriverLicenseV1.java @@ -1,8 +1,8 @@ -package com.mindee.product.driverlicense; +package com.mindee.v1.product.driverlicense; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/driverlicense/DriverLicenseV1Document.java b/src/main/java/com/mindee/v1/product/driverlicense/DriverLicenseV1Document.java similarity index 93% rename from src/main/java/com/mindee/product/driverlicense/DriverLicenseV1Document.java rename to src/main/java/com/mindee/v1/product/driverlicense/DriverLicenseV1Document.java index 3808b5250..6401ade0d 100644 --- a/src/main/java/com/mindee/product/driverlicense/DriverLicenseV1Document.java +++ b/src/main/java/com/mindee/v1/product/driverlicense/DriverLicenseV1Document.java @@ -1,11 +1,11 @@ -package com.mindee.product.driverlicense; +package com.mindee.v1.product.driverlicense; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.StringField; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1.java b/src/main/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1.java similarity index 73% rename from src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1.java rename to src/main/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1.java index 758f9839b..4c10a0a7b 100644 --- a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1.java +++ b/src/main/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1.java @@ -1,8 +1,8 @@ -package com.mindee.product.financialdocument; +package com.mindee.v1.product.financialdocument; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java b/src/main/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1Document.java similarity index 94% rename from src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java rename to src/main/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1Document.java index 2f879df7d..f843f798c 100644 --- a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java +++ b/src/main/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1Document.java @@ -1,20 +1,20 @@ -package com.mindee.product.financialdocument; +package com.mindee.v1.product.financialdocument; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.AddressField; -import com.mindee.parsing.standard.AmountField; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.parsing.standard.CompanyRegistrationField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.LocaleField; -import com.mindee.parsing.standard.PaymentDetailsField; -import com.mindee.parsing.standard.StringField; -import com.mindee.parsing.standard.Taxes; -import com.mindee.parsing.standard.TaxesDeserializer; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.AddressField; +import com.mindee.v1.parsing.standard.AmountField; +import com.mindee.v1.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.standard.CompanyRegistrationField; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.LocaleField; +import com.mindee.v1.parsing.standard.PaymentDetailsField; +import com.mindee.v1.parsing.standard.StringField; +import com.mindee.v1.parsing.standard.Taxes; +import com.mindee.v1.parsing.standard.TaxesDeserializer; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1LineItem.java b/src/main/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1LineItem.java similarity index 95% rename from src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1LineItem.java rename to src/main/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1LineItem.java index 47ec3a696..b9a6ffcd0 100644 --- a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1LineItem.java +++ b/src/main/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1LineItem.java @@ -1,10 +1,10 @@ -package com.mindee.product.financialdocument; +package com.mindee.v1.product.financialdocument; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.standard.BaseField; +import com.mindee.v1.parsing.standard.LineItemField; import java.util.HashMap; import java.util.Map; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2.java b/src/main/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2.java similarity index 73% rename from src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2.java rename to src/main/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2.java index edadc921f..8fc466651 100644 --- a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2.java +++ b/src/main/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2.java @@ -1,8 +1,8 @@ -package com.mindee.product.fr.bankaccountdetails; +package com.mindee.v1.product.fr.bankaccountdetails; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java b/src/main/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java similarity index 94% rename from src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java rename to src/main/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java index ea4829175..85631d8d0 100644 --- a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java +++ b/src/main/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java @@ -1,9 +1,9 @@ -package com.mindee.product.fr.bankaccountdetails; +package com.mindee.v1.product.fr.bankaccountdetails; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.standard.BaseField; import java.util.HashMap; import java.util.Map; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Document.java b/src/main/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2Document.java similarity index 89% rename from src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Document.java rename to src/main/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2Document.java index 78d914c05..3f5f902d4 100644 --- a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Document.java +++ b/src/main/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2Document.java @@ -1,10 +1,10 @@ -package com.mindee.product.fr.bankaccountdetails; +package com.mindee.v1.product.fr.bankaccountdetails; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.StringField; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/fr/cartegrise/CarteGriseV1.java b/src/main/java/com/mindee/v1/product/fr/cartegrise/CarteGriseV1.java similarity index 72% rename from src/main/java/com/mindee/product/fr/cartegrise/CarteGriseV1.java rename to src/main/java/com/mindee/v1/product/fr/cartegrise/CarteGriseV1.java index 686c557e7..ce627ecba 100644 --- a/src/main/java/com/mindee/product/fr/cartegrise/CarteGriseV1.java +++ b/src/main/java/com/mindee/v1/product/fr/cartegrise/CarteGriseV1.java @@ -1,8 +1,8 @@ -package com.mindee.product.fr.cartegrise; +package com.mindee.v1.product.fr.cartegrise; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/fr/cartegrise/CarteGriseV1Document.java b/src/main/java/com/mindee/v1/product/fr/cartegrise/CarteGriseV1Document.java similarity index 97% rename from src/main/java/com/mindee/product/fr/cartegrise/CarteGriseV1Document.java rename to src/main/java/com/mindee/v1/product/fr/cartegrise/CarteGriseV1Document.java index 16f505af7..c7dc3dfae 100644 --- a/src/main/java/com/mindee/product/fr/cartegrise/CarteGriseV1Document.java +++ b/src/main/java/com/mindee/v1/product/fr/cartegrise/CarteGriseV1Document.java @@ -1,11 +1,11 @@ -package com.mindee.product.fr.cartegrise; +package com.mindee.v1.product.fr.cartegrise; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.StringField; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/fr/idcard/IdCardV1.java b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV1.java similarity index 72% rename from src/main/java/com/mindee/product/fr/idcard/IdCardV1.java rename to src/main/java/com/mindee/v1/product/fr/idcard/IdCardV1.java index af8cda05c..2e7777ce5 100644 --- a/src/main/java/com/mindee/product/fr/idcard/IdCardV1.java +++ b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV1.java @@ -1,8 +1,8 @@ -package com.mindee.product.fr.idcard; +package com.mindee.v1.product.fr.idcard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/fr/idcard/IdCardV1Document.java b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV1Document.java similarity index 92% rename from src/main/java/com/mindee/product/fr/idcard/IdCardV1Document.java rename to src/main/java/com/mindee/v1/product/fr/idcard/IdCardV1Document.java index 7af2b21e7..1d9ea8485 100644 --- a/src/main/java/com/mindee/product/fr/idcard/IdCardV1Document.java +++ b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV1Document.java @@ -1,11 +1,11 @@ -package com.mindee.product.fr.idcard; +package com.mindee.v1.product.fr.idcard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.StringField; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/fr/idcard/IdCardV1Page.java b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV1Page.java similarity index 85% rename from src/main/java/com/mindee/product/fr/idcard/IdCardV1Page.java rename to src/main/java/com/mindee/v1/product/fr/idcard/IdCardV1Page.java index 3d2b2c58e..0287ff1d4 100644 --- a/src/main/java/com/mindee/product/fr/idcard/IdCardV1Page.java +++ b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV1Page.java @@ -1,9 +1,9 @@ -package com.mindee.product.fr.idcard; +package com.mindee.v1.product.fr.idcard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.standard.ClassificationField; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/fr/idcard/IdCardV2.java b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV2.java similarity index 72% rename from src/main/java/com/mindee/product/fr/idcard/IdCardV2.java rename to src/main/java/com/mindee/v1/product/fr/idcard/IdCardV2.java index feb577e14..9338e2275 100644 --- a/src/main/java/com/mindee/product/fr/idcard/IdCardV2.java +++ b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV2.java @@ -1,8 +1,8 @@ -package com.mindee.product.fr.idcard; +package com.mindee.v1.product.fr.idcard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/fr/idcard/IdCardV2Document.java b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV2Document.java similarity index 94% rename from src/main/java/com/mindee/product/fr/idcard/IdCardV2Document.java rename to src/main/java/com/mindee/v1/product/fr/idcard/IdCardV2Document.java index 54754f6b9..5fb072187 100644 --- a/src/main/java/com/mindee/product/fr/idcard/IdCardV2Document.java +++ b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV2Document.java @@ -1,11 +1,11 @@ -package com.mindee.product.fr.idcard; +package com.mindee.v1.product.fr.idcard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.StringField; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/fr/idcard/IdCardV2Page.java b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV2Page.java similarity index 88% rename from src/main/java/com/mindee/product/fr/idcard/IdCardV2Page.java rename to src/main/java/com/mindee/v1/product/fr/idcard/IdCardV2Page.java index e24661128..bdf4f1a6a 100644 --- a/src/main/java/com/mindee/product/fr/idcard/IdCardV2Page.java +++ b/src/main/java/com/mindee/v1/product/fr/idcard/IdCardV2Page.java @@ -1,9 +1,9 @@ -package com.mindee.product.fr.idcard; +package com.mindee.v1.product.fr.idcard; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.standard.ClassificationField; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/generated/GeneratedV1.java b/src/main/java/com/mindee/v1/product/generated/GeneratedV1.java similarity index 77% rename from src/main/java/com/mindee/product/generated/GeneratedV1.java rename to src/main/java/com/mindee/v1/product/generated/GeneratedV1.java index ca938561b..820aca1d9 100644 --- a/src/main/java/com/mindee/product/generated/GeneratedV1.java +++ b/src/main/java/com/mindee/v1/product/generated/GeneratedV1.java @@ -1,7 +1,7 @@ -package com.mindee.product.generated; +package com.mindee.v1.product.generated; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/generated/GeneratedV1Document.java b/src/main/java/com/mindee/v1/product/generated/GeneratedV1Document.java similarity index 83% rename from src/main/java/com/mindee/product/generated/GeneratedV1Document.java rename to src/main/java/com/mindee/v1/product/generated/GeneratedV1Document.java index d0a849ed6..64f954268 100644 --- a/src/main/java/com/mindee/product/generated/GeneratedV1Document.java +++ b/src/main/java/com/mindee/v1/product/generated/GeneratedV1Document.java @@ -1,10 +1,10 @@ -package com.mindee.product.generated; +package com.mindee.v1.product.generated; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.generated.GeneratedFeature; -import com.mindee.parsing.generated.GeneratedV1PredictionDeserializer; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.generated.GeneratedFeature; +import com.mindee.v1.parsing.generated.GeneratedV1PredictionDeserializer; import java.util.Map; import java.util.TreeMap; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/mindee/product/ind/indianpassport/IndianPassportV1.java b/src/main/java/com/mindee/v1/product/ind/indianpassport/IndianPassportV1.java similarity index 72% rename from src/main/java/com/mindee/product/ind/indianpassport/IndianPassportV1.java rename to src/main/java/com/mindee/v1/product/ind/indianpassport/IndianPassportV1.java index 76dfdb7cb..809487848 100644 --- a/src/main/java/com/mindee/product/ind/indianpassport/IndianPassportV1.java +++ b/src/main/java/com/mindee/v1/product/ind/indianpassport/IndianPassportV1.java @@ -1,8 +1,8 @@ -package com.mindee.product.ind.indianpassport; +package com.mindee.v1.product.ind.indianpassport; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/ind/indianpassport/IndianPassportV1Document.java b/src/main/java/com/mindee/v1/product/ind/indianpassport/IndianPassportV1Document.java similarity index 95% rename from src/main/java/com/mindee/product/ind/indianpassport/IndianPassportV1Document.java rename to src/main/java/com/mindee/v1/product/ind/indianpassport/IndianPassportV1Document.java index 85b7de6e4..d7a78fed8 100644 --- a/src/main/java/com/mindee/product/ind/indianpassport/IndianPassportV1Document.java +++ b/src/main/java/com/mindee/v1/product/ind/indianpassport/IndianPassportV1Document.java @@ -1,12 +1,12 @@ -package com.mindee.product.ind.indianpassport; +package com.mindee.v1.product.ind.indianpassport; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.StringField; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/internationalid/InternationalIdV2.java b/src/main/java/com/mindee/v1/product/internationalid/InternationalIdV2.java similarity index 73% rename from src/main/java/com/mindee/product/internationalid/InternationalIdV2.java rename to src/main/java/com/mindee/v1/product/internationalid/InternationalIdV2.java index fbc6a60ec..fda49aa6e 100644 --- a/src/main/java/com/mindee/product/internationalid/InternationalIdV2.java +++ b/src/main/java/com/mindee/v1/product/internationalid/InternationalIdV2.java @@ -1,8 +1,8 @@ -package com.mindee.product.internationalid; +package com.mindee.v1.product.internationalid; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/internationalid/InternationalIdV2Document.java b/src/main/java/com/mindee/v1/product/internationalid/InternationalIdV2Document.java similarity index 94% rename from src/main/java/com/mindee/product/internationalid/InternationalIdV2Document.java rename to src/main/java/com/mindee/v1/product/internationalid/InternationalIdV2Document.java index a473f56dc..9da9afe81 100644 --- a/src/main/java/com/mindee/product/internationalid/InternationalIdV2Document.java +++ b/src/main/java/com/mindee/v1/product/internationalid/InternationalIdV2Document.java @@ -1,12 +1,12 @@ -package com.mindee.product.internationalid; +package com.mindee.v1.product.internationalid; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.StringField; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/invoice/InvoiceV4.java b/src/main/java/com/mindee/v1/product/invoice/InvoiceV4.java similarity index 72% rename from src/main/java/com/mindee/product/invoice/InvoiceV4.java rename to src/main/java/com/mindee/v1/product/invoice/InvoiceV4.java index 4688476f7..e53b6fffb 100644 --- a/src/main/java/com/mindee/product/invoice/InvoiceV4.java +++ b/src/main/java/com/mindee/v1/product/invoice/InvoiceV4.java @@ -1,8 +1,8 @@ -package com.mindee.product.invoice; +package com.mindee.v1.product.invoice; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/invoice/InvoiceV4Document.java b/src/main/java/com/mindee/v1/product/invoice/InvoiceV4Document.java similarity index 93% rename from src/main/java/com/mindee/product/invoice/InvoiceV4Document.java rename to src/main/java/com/mindee/v1/product/invoice/InvoiceV4Document.java index 6fd1daf1f..bc80c9542 100644 --- a/src/main/java/com/mindee/product/invoice/InvoiceV4Document.java +++ b/src/main/java/com/mindee/v1/product/invoice/InvoiceV4Document.java @@ -1,20 +1,20 @@ -package com.mindee.product.invoice; +package com.mindee.v1.product.invoice; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.AddressField; -import com.mindee.parsing.standard.AmountField; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.parsing.standard.CompanyRegistrationField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.LocaleField; -import com.mindee.parsing.standard.PaymentDetailsField; -import com.mindee.parsing.standard.StringField; -import com.mindee.parsing.standard.Taxes; -import com.mindee.parsing.standard.TaxesDeserializer; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.AddressField; +import com.mindee.v1.parsing.standard.AmountField; +import com.mindee.v1.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.standard.CompanyRegistrationField; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.LocaleField; +import com.mindee.v1.parsing.standard.PaymentDetailsField; +import com.mindee.v1.parsing.standard.StringField; +import com.mindee.v1.parsing.standard.Taxes; +import com.mindee.v1.parsing.standard.TaxesDeserializer; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/invoice/InvoiceV4LineItem.java b/src/main/java/com/mindee/v1/product/invoice/InvoiceV4LineItem.java similarity index 95% rename from src/main/java/com/mindee/product/invoice/InvoiceV4LineItem.java rename to src/main/java/com/mindee/v1/product/invoice/InvoiceV4LineItem.java index 6d50cdfdd..cd7932838 100644 --- a/src/main/java/com/mindee/product/invoice/InvoiceV4LineItem.java +++ b/src/main/java/com/mindee/v1/product/invoice/InvoiceV4LineItem.java @@ -1,10 +1,10 @@ -package com.mindee.product.invoice; +package com.mindee.v1.product.invoice; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.standard.BaseField; +import com.mindee.v1.parsing.standard.LineItemField; import java.util.HashMap; import java.util.Map; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1.java b/src/main/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1.java similarity index 73% rename from src/main/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1.java rename to src/main/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1.java index e115f419e..cef139b15 100644 --- a/src/main/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1.java +++ b/src/main/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1.java @@ -1,8 +1,8 @@ -package com.mindee.product.invoicesplitter; +package com.mindee.v1.product.invoicesplitter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1Document.java b/src/main/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1Document.java similarity index 92% rename from src/main/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1Document.java rename to src/main/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1Document.java index 773c7991f..c4fb27c11 100644 --- a/src/main/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1Document.java +++ b/src/main/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1Document.java @@ -1,9 +1,9 @@ -package com.mindee.product.invoicesplitter; +package com.mindee.v1.product.invoicesplitter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1InvoicePageGroup.java b/src/main/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1InvoicePageGroup.java similarity index 91% rename from src/main/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1InvoicePageGroup.java rename to src/main/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1InvoicePageGroup.java index 50f56f91e..3a781f4d6 100644 --- a/src/main/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1InvoicePageGroup.java +++ b/src/main/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1InvoicePageGroup.java @@ -1,9 +1,9 @@ -package com.mindee.product.invoicesplitter; +package com.mindee.v1.product.invoicesplitter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; +import com.mindee.v1.parsing.standard.BaseField; +import com.mindee.v1.parsing.standard.LineItemField; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/src/main/java/com/mindee/product/multireceiptsdetector/MultiReceiptsDetectorV1.java b/src/main/java/com/mindee/v1/product/multireceiptsdetector/MultiReceiptsDetectorV1.java similarity index 74% rename from src/main/java/com/mindee/product/multireceiptsdetector/MultiReceiptsDetectorV1.java rename to src/main/java/com/mindee/v1/product/multireceiptsdetector/MultiReceiptsDetectorV1.java index 53fa8787d..1e9dc0f25 100644 --- a/src/main/java/com/mindee/product/multireceiptsdetector/MultiReceiptsDetectorV1.java +++ b/src/main/java/com/mindee/v1/product/multireceiptsdetector/MultiReceiptsDetectorV1.java @@ -1,8 +1,8 @@ -package com.mindee.product.multireceiptsdetector; +package com.mindee.v1.product.multireceiptsdetector; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/multireceiptsdetector/MultiReceiptsDetectorV1Document.java b/src/main/java/com/mindee/v1/product/multireceiptsdetector/MultiReceiptsDetectorV1Document.java similarity index 83% rename from src/main/java/com/mindee/product/multireceiptsdetector/MultiReceiptsDetectorV1Document.java rename to src/main/java/com/mindee/v1/product/multireceiptsdetector/MultiReceiptsDetectorV1Document.java index 64d6f6d25..6d4682e66 100644 --- a/src/main/java/com/mindee/product/multireceiptsdetector/MultiReceiptsDetectorV1Document.java +++ b/src/main/java/com/mindee/v1/product/multireceiptsdetector/MultiReceiptsDetectorV1Document.java @@ -1,10 +1,10 @@ -package com.mindee.product.multireceiptsdetector; +package com.mindee.v1.product.multireceiptsdetector; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.PositionField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.PositionField; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/passport/PassportV1.java b/src/main/java/com/mindee/v1/product/passport/PassportV1.java similarity index 72% rename from src/main/java/com/mindee/product/passport/PassportV1.java rename to src/main/java/com/mindee/v1/product/passport/PassportV1.java index d9549530b..4cb8700ef 100644 --- a/src/main/java/com/mindee/product/passport/PassportV1.java +++ b/src/main/java/com/mindee/v1/product/passport/PassportV1.java @@ -1,8 +1,8 @@ -package com.mindee.product.passport; +package com.mindee.v1.product.passport; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/passport/PassportV1Document.java b/src/main/java/com/mindee/v1/product/passport/PassportV1Document.java similarity index 93% rename from src/main/java/com/mindee/product/passport/PassportV1Document.java rename to src/main/java/com/mindee/v1/product/passport/PassportV1Document.java index feeb9a1bf..f8e7a03ac 100644 --- a/src/main/java/com/mindee/product/passport/PassportV1Document.java +++ b/src/main/java/com/mindee/v1/product/passport/PassportV1Document.java @@ -1,11 +1,11 @@ -package com.mindee.product.passport; +package com.mindee.v1.product.passport; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.StringField; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/receipt/ReceiptV5.java b/src/main/java/com/mindee/v1/product/receipt/ReceiptV5.java similarity index 72% rename from src/main/java/com/mindee/product/receipt/ReceiptV5.java rename to src/main/java/com/mindee/v1/product/receipt/ReceiptV5.java index 64c071e54..289c32130 100644 --- a/src/main/java/com/mindee/product/receipt/ReceiptV5.java +++ b/src/main/java/com/mindee/v1/product/receipt/ReceiptV5.java @@ -1,8 +1,8 @@ -package com.mindee.product.receipt; +package com.mindee.v1.product.receipt; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; +import com.mindee.v1.http.EndpointInfo; +import com.mindee.v1.parsing.common.Inference; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/product/receipt/ReceiptV5Document.java b/src/main/java/com/mindee/v1/product/receipt/ReceiptV5Document.java similarity index 91% rename from src/main/java/com/mindee/product/receipt/ReceiptV5Document.java rename to src/main/java/com/mindee/v1/product/receipt/ReceiptV5Document.java index 1234964b6..6ca34663e 100644 --- a/src/main/java/com/mindee/product/receipt/ReceiptV5Document.java +++ b/src/main/java/com/mindee/v1/product/receipt/ReceiptV5Document.java @@ -1,18 +1,18 @@ -package com.mindee.product.receipt; +package com.mindee.v1.product.receipt; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.AmountField; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.parsing.standard.CompanyRegistrationField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.LocaleField; -import com.mindee.parsing.standard.StringField; -import com.mindee.parsing.standard.Taxes; -import com.mindee.parsing.standard.TaxesDeserializer; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.common.Prediction; +import com.mindee.v1.parsing.standard.AmountField; +import com.mindee.v1.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.standard.CompanyRegistrationField; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.LocaleField; +import com.mindee.v1.parsing.standard.StringField; +import com.mindee.v1.parsing.standard.Taxes; +import com.mindee.v1.parsing.standard.TaxesDeserializer; import java.util.ArrayList; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/product/receipt/ReceiptV5LineItem.java b/src/main/java/com/mindee/v1/product/receipt/ReceiptV5LineItem.java similarity index 93% rename from src/main/java/com/mindee/product/receipt/ReceiptV5LineItem.java rename to src/main/java/com/mindee/v1/product/receipt/ReceiptV5LineItem.java index 75ac5ca57..23859c4a3 100644 --- a/src/main/java/com/mindee/product/receipt/ReceiptV5LineItem.java +++ b/src/main/java/com/mindee/v1/product/receipt/ReceiptV5LineItem.java @@ -1,10 +1,10 @@ -package com.mindee.product.receipt; +package com.mindee.v1.product.receipt; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.BaseField; -import com.mindee.parsing.standard.LineItemField; +import com.mindee.v1.parsing.SummaryHelper; +import com.mindee.v1.parsing.standard.BaseField; +import com.mindee.v1.parsing.standard.LineItemField; import java.util.HashMap; import java.util.Map; import lombok.Getter; diff --git a/src/main/java/com/mindee/MindeeClientV2.java b/src/main/java/com/mindee/v2/MindeeClient.java similarity index 80% rename from src/main/java/com/mindee/MindeeClientV2.java rename to src/main/java/com/mindee/v2/MindeeClient.java index 9dc2f23f3..520494d6b 100644 --- a/src/main/java/com/mindee/MindeeClientV2.java +++ b/src/main/java/com/mindee/v2/MindeeClient.java @@ -1,35 +1,36 @@ -package com.mindee; +package com.mindee.v2; -import com.mindee.http.MindeeApiV2; -import com.mindee.http.MindeeHttpApiV2; -import com.mindee.http.MindeeHttpExceptionV2; import com.mindee.input.LocalInputSource; import com.mindee.input.URLInputSource; -import com.mindee.parsing.v2.CommonResponse; -import com.mindee.parsing.v2.ErrorResponse; -import com.mindee.parsing.v2.InferenceResponse; -import com.mindee.parsing.v2.JobResponse; import com.mindee.v2.clientOptions.BaseParameters; +import com.mindee.v2.http.MindeeApiV2; +import com.mindee.v2.http.MindeeHttpApiV2; +import com.mindee.v2.http.MindeeHttpExceptionV2; +import com.mindee.v2.parsing.CommonResponse; +import com.mindee.v2.parsing.ErrorResponse; +import com.mindee.v2.parsing.JobResponse; +import com.mindee.v2.product.extraction.ExtractionResponse; +import com.mindee.v2.product.extraction.params.ExtractionParameters; import java.io.IOException; /** * Entry point for the Mindee **V2** API features. */ -public class MindeeClientV2 { +public class MindeeClient { private final MindeeApiV2 mindeeApi; /** Uses an API key read from the environment variables. */ - public MindeeClientV2() { + public MindeeClient() { this(createDefaultApiV2("")); } /** Uses the supplied API key. */ - public MindeeClientV2(String apiKey) { + public MindeeClient(String apiKey) { this(createDefaultApiV2(apiKey)); } /** Inject both a PDF implementation and an HTTP implementation. */ - public MindeeClientV2(MindeeApiV2 mindeeApi) { + public MindeeClient(MindeeApiV2 mindeeApi) { this.mindeeApi = mindeeApi; } @@ -38,7 +39,7 @@ public MindeeClientV2(MindeeApiV2 mindeeApi) { */ public JobResponse enqueueInference( LocalInputSource inputSource, - InferenceParameters params + ExtractionParameters params ) throws IOException { return enqueue(inputSource, params); } @@ -48,7 +49,7 @@ public JobResponse enqueueInference( */ public JobResponse enqueueInference( URLInputSource inputSource, - InferenceParameters params + ExtractionParameters params ) throws IOException { return enqueue(inputSource, params); } @@ -90,8 +91,8 @@ public JobResponse getJob(String jobId) { /** * @deprecated use `getResult` instead. */ - public InferenceResponse getInference(String inferenceId) { - return getResult(InferenceResponse.class, inferenceId); + public ExtractionResponse getInference(String inferenceId) { + return getResult(ExtractionResponse.class, inferenceId); } /** @@ -111,21 +112,21 @@ public TResponse getResult( /** * @deprecated use `enqueueAndGetResult` instead. */ - public InferenceResponse enqueueAndGetInference( + public ExtractionResponse enqueueAndGetInference( LocalInputSource inputSource, - InferenceParameters options + ExtractionParameters options ) throws IOException, InterruptedException { - return enqueueAndGetResult(InferenceResponse.class, inputSource, options); + return enqueueAndGetResult(ExtractionResponse.class, inputSource, options); } /** * @deprecated use `enqueueAndGetResult` instead. */ - public InferenceResponse enqueueAndGetInference( + public ExtractionResponse enqueueAndGetInference( URLInputSource inputSource, - InferenceParameters options + ExtractionParameters options ) throws IOException, InterruptedException { - return enqueueAndGetResult(InferenceResponse.class, inputSource, options); + return enqueueAndGetResult(ExtractionResponse.class, inputSource, options); } /** @@ -133,7 +134,7 @@ public InferenceResponse enqueueAndGetInference( * * @param inputSource The local input source to send. * @param params The parameters to send along with the file. - * @return an instance of {@link InferenceResponse}. + * @return an instance of {@link ExtractionResponse}. * @throws IOException Throws if the file can't be accessed. * @throws InterruptedException Throws if the thread is interrupted. */ @@ -152,7 +153,7 @@ public TResponse enqueueAndGetResult( * * @param inputSource The URL input source to send. * @param params The parameters to send along with the file. - * @return an instance of {@link InferenceResponse}. + * @return an instance of {@link ExtractionResponse}. * @throws IOException Throws if the file can't be accessed. * @throws InterruptedException Throws if the thread is interrupted. */ @@ -170,7 +171,7 @@ public TResponse enqueueAndGetResult( * Common logic for polling an asynchronous job for local & url files. * * @param initialJob The initial job response. - * @return an instance of {@link InferenceResponse}. + * @return an instance of {@link ExtractionResponse}. * @throws InterruptedException Throws if interrupted. */ private TResponse pollAndFetch( @@ -205,9 +206,9 @@ private TResponse pollAndFetch( } private static MindeeApiV2 createDefaultApiV2(String apiKey) { - MindeeSettingsV2 settings = apiKey == null || apiKey.trim().isEmpty() - ? new MindeeSettingsV2() - : new MindeeSettingsV2(apiKey); + MindeeSettings settings = apiKey == null || apiKey.trim().isEmpty() + ? new MindeeSettings() + : new MindeeSettings(apiKey); return MindeeHttpApiV2.builder().mindeeSettings(settings).build(); } } diff --git a/src/main/java/com/mindee/MindeeSettingsV2.java b/src/main/java/com/mindee/v2/MindeeSettings.java similarity index 85% rename from src/main/java/com/mindee/MindeeSettingsV2.java rename to src/main/java/com/mindee/v2/MindeeSettings.java index 3d95ba56a..36666ac52 100644 --- a/src/main/java/com/mindee/MindeeSettingsV2.java +++ b/src/main/java/com/mindee/v2/MindeeSettings.java @@ -1,4 +1,4 @@ -package com.mindee; +package com.mindee.v2; import java.util.Optional; import lombok.Builder; @@ -9,13 +9,13 @@ */ @Getter @Builder -public class MindeeSettingsV2 { +public class MindeeSettings { private static final String DEFAULT_MINDEE_V2_API_URL = "https://api-v2.mindee.net/v2"; private final String apiKey; private final String baseUrl; - public MindeeSettingsV2() { + public MindeeSettings() { this("", ""); } @@ -23,11 +23,11 @@ public Optional getApiKey() { return Optional.ofNullable(apiKey); } - public MindeeSettingsV2(String apiKey) { + public MindeeSettings(String apiKey) { this(apiKey, ""); } - public MindeeSettingsV2(String apiKey, String baseUrl) { + public MindeeSettings(String apiKey, String baseUrl) { if (apiKey == null || apiKey.trim().isEmpty()) { String apiKeyFromEnv = System.getenv("MINDEE_V2_API_KEY"); diff --git a/src/main/java/com/mindee/http/MindeeApiV2.java b/src/main/java/com/mindee/v2/http/MindeeApiV2.java similarity index 92% rename from src/main/java/com/mindee/http/MindeeApiV2.java rename to src/main/java/com/mindee/v2/http/MindeeApiV2.java index c93db9791..197e7b5fd 100644 --- a/src/main/java/com/mindee/http/MindeeApiV2.java +++ b/src/main/java/com/mindee/v2/http/MindeeApiV2.java @@ -1,13 +1,13 @@ -package com.mindee.http; +package com.mindee.v2.http; import com.mindee.MindeeException; +import com.mindee.http.MindeeApiCommon; import com.mindee.input.LocalInputSource; import com.mindee.input.URLInputSource; -import com.mindee.parsing.v2.CommonResponse; -import com.mindee.parsing.v2.ErrorResponse; -import com.mindee.parsing.v2.JobResponse; import com.mindee.v2.clientOptions.BaseParameters; -import com.mindee.v2.http.ProductInfo; +import com.mindee.v2.parsing.CommonResponse; +import com.mindee.v2.parsing.ErrorResponse; +import com.mindee.v2.parsing.JobResponse; import java.io.IOException; /** diff --git a/src/main/java/com/mindee/http/MindeeHttpApiV2.java b/src/main/java/com/mindee/v2/http/MindeeHttpApiV2.java similarity index 95% rename from src/main/java/com/mindee/http/MindeeHttpApiV2.java rename to src/main/java/com/mindee/v2/http/MindeeHttpApiV2.java index 0f15df371..0a01686d4 100644 --- a/src/main/java/com/mindee/http/MindeeHttpApiV2.java +++ b/src/main/java/com/mindee/v2/http/MindeeHttpApiV2.java @@ -1,16 +1,15 @@ -package com.mindee.http; +package com.mindee.v2.http; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; import com.mindee.MindeeException; -import com.mindee.MindeeSettingsV2; import com.mindee.input.LocalInputSource; import com.mindee.input.URLInputSource; -import com.mindee.parsing.v2.CommonResponse; -import com.mindee.parsing.v2.ErrorResponse; -import com.mindee.parsing.v2.JobResponse; +import com.mindee.v2.MindeeSettings; import com.mindee.v2.clientOptions.BaseParameters; -import com.mindee.v2.http.ProductInfo; +import com.mindee.v2.parsing.CommonResponse; +import com.mindee.v2.parsing.ErrorResponse; +import com.mindee.v2.parsing.JobResponse; import java.io.IOException; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; @@ -39,19 +38,19 @@ public final class MindeeHttpApiV2 extends MindeeApiV2 { /** * The MindeeSetting needed to make the api call. */ - private final MindeeSettingsV2 mindeeSettings; + private final MindeeSettings mindeeSettings; /** * The HttpClientBuilder used to create HttpClient objects used to make api calls over http. * Defaults to HttpClientBuilder.create().useSystemProperties() */ private final HttpClientBuilder httpClientBuilder; - public MindeeHttpApiV2(MindeeSettingsV2 mindeeSettings) { + public MindeeHttpApiV2(MindeeSettings mindeeSettings) { this(mindeeSettings, null); } @Builder - private MindeeHttpApiV2(MindeeSettingsV2 mindeeSettings, HttpClientBuilder httpClientBuilder) { + private MindeeHttpApiV2(MindeeSettings mindeeSettings, HttpClientBuilder httpClientBuilder) { this.mindeeSettings = mindeeSettings; if (httpClientBuilder != null) { diff --git a/src/main/java/com/mindee/http/MindeeHttpExceptionV2.java b/src/main/java/com/mindee/v2/http/MindeeHttpExceptionV2.java similarity index 95% rename from src/main/java/com/mindee/http/MindeeHttpExceptionV2.java rename to src/main/java/com/mindee/v2/http/MindeeHttpExceptionV2.java index 86db6657e..409ca231e 100644 --- a/src/main/java/com/mindee/http/MindeeHttpExceptionV2.java +++ b/src/main/java/com/mindee/v2/http/MindeeHttpExceptionV2.java @@ -1,4 +1,4 @@ -package com.mindee.http; +package com.mindee.v2.http; import com.mindee.MindeeException; import lombok.Getter; diff --git a/src/main/java/com/mindee/v2/parsing/BaseInference.java b/src/main/java/com/mindee/v2/parsing/BaseInference.java index 26053d457..daa22b9fd 100644 --- a/src/main/java/com/mindee/v2/parsing/BaseInference.java +++ b/src/main/java/com/mindee/v2/parsing/BaseInference.java @@ -2,7 +2,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.v2.*; +import com.mindee.v2.parsing.inference.InferenceFile; +import com.mindee.v2.parsing.inference.InferenceJob; +import com.mindee.v2.parsing.inference.InferenceModel; import java.util.StringJoiner; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/parsing/v2/CommonResponse.java b/src/main/java/com/mindee/v2/parsing/CommonResponse.java similarity index 93% rename from src/main/java/com/mindee/parsing/v2/CommonResponse.java rename to src/main/java/com/mindee/v2/parsing/CommonResponse.java index 72f625f3f..807a3b2ca 100644 --- a/src/main/java/com/mindee/parsing/v2/CommonResponse.java +++ b/src/main/java/com/mindee/v2/parsing/CommonResponse.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Data; diff --git a/src/main/java/com/mindee/parsing/v2/ErrorItem.java b/src/main/java/com/mindee/v2/parsing/ErrorItem.java similarity index 95% rename from src/main/java/com/mindee/parsing/v2/ErrorItem.java rename to src/main/java/com/mindee/v2/parsing/ErrorItem.java index 8d70edad1..da1a9917d 100644 --- a/src/main/java/com/mindee/parsing/v2/ErrorItem.java +++ b/src/main/java/com/mindee/v2/parsing/ErrorItem.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/ErrorResponse.java b/src/main/java/com/mindee/v2/parsing/ErrorResponse.java similarity index 97% rename from src/main/java/com/mindee/parsing/v2/ErrorResponse.java rename to src/main/java/com/mindee/v2/parsing/ErrorResponse.java index bd81b579f..9aebb55cd 100644 --- a/src/main/java/com/mindee/parsing/v2/ErrorResponse.java +++ b/src/main/java/com/mindee/v2/parsing/ErrorResponse.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/Job.java b/src/main/java/com/mindee/v2/parsing/Job.java similarity index 95% rename from src/main/java/com/mindee/parsing/v2/Job.java rename to src/main/java/com/mindee/v2/parsing/Job.java index 1080f5b6c..8d260e3fb 100644 --- a/src/main/java/com/mindee/parsing/v2/Job.java +++ b/src/main/java/com/mindee/v2/parsing/Job.java @@ -1,9 +1,9 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.parsing.common.LocalDateTimeDeserializer; +import com.mindee.v1.parsing.common.LocalDateTimeDeserializer; import java.time.LocalDateTime; import java.util.List; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/mindee/parsing/v2/JobResponse.java b/src/main/java/com/mindee/v2/parsing/JobResponse.java similarity index 93% rename from src/main/java/com/mindee/parsing/v2/JobResponse.java rename to src/main/java/com/mindee/v2/parsing/JobResponse.java index 0753d1cd3..1f99052d1 100644 --- a/src/main/java/com/mindee/parsing/v2/JobResponse.java +++ b/src/main/java/com/mindee/v2/parsing/JobResponse.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/JobWebhook.java b/src/main/java/com/mindee/v2/parsing/JobWebhook.java similarity index 91% rename from src/main/java/com/mindee/parsing/v2/JobWebhook.java rename to src/main/java/com/mindee/v2/parsing/JobWebhook.java index 1a892eb69..fd3af5489 100644 --- a/src/main/java/com/mindee/parsing/v2/JobWebhook.java +++ b/src/main/java/com/mindee/v2/parsing/JobWebhook.java @@ -1,9 +1,9 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.parsing.common.LocalDateTimeDeserializer; +import com.mindee.v1.parsing.common.LocalDateTimeDeserializer; import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/mindee/parsing/v2/DataSchemaActiveOptions.java b/src/main/java/com/mindee/v2/parsing/inference/DataSchemaActiveOptions.java similarity index 95% rename from src/main/java/com/mindee/parsing/v2/DataSchemaActiveOptions.java rename to src/main/java/com/mindee/v2/parsing/inference/DataSchemaActiveOptions.java index 5d14c28f2..0b3898dde 100644 --- a/src/main/java/com/mindee/parsing/v2/DataSchemaActiveOptions.java +++ b/src/main/java/com/mindee/v2/parsing/inference/DataSchemaActiveOptions.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing.inference; import static com.mindee.parsing.SummaryHelper.formatForDisplay; diff --git a/src/main/java/com/mindee/parsing/v2/InferenceActiveOptions.java b/src/main/java/com/mindee/v2/parsing/inference/InferenceActiveOptions.java similarity index 97% rename from src/main/java/com/mindee/parsing/v2/InferenceActiveOptions.java rename to src/main/java/com/mindee/v2/parsing/inference/InferenceActiveOptions.java index 96fbc27b4..5ecbdc047 100644 --- a/src/main/java/com/mindee/parsing/v2/InferenceActiveOptions.java +++ b/src/main/java/com/mindee/v2/parsing/inference/InferenceActiveOptions.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing.inference; import static com.mindee.parsing.SummaryHelper.formatForDisplay; diff --git a/src/main/java/com/mindee/parsing/v2/InferenceFile.java b/src/main/java/com/mindee/v2/parsing/inference/InferenceFile.java similarity index 96% rename from src/main/java/com/mindee/parsing/v2/InferenceFile.java rename to src/main/java/com/mindee/v2/parsing/inference/InferenceFile.java index 4276b969a..f8c963601 100644 --- a/src/main/java/com/mindee/parsing/v2/InferenceFile.java +++ b/src/main/java/com/mindee/v2/parsing/inference/InferenceFile.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing.inference; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/InferenceJob.java b/src/main/java/com/mindee/v2/parsing/inference/InferenceJob.java similarity index 94% rename from src/main/java/com/mindee/parsing/v2/InferenceJob.java rename to src/main/java/com/mindee/v2/parsing/inference/InferenceJob.java index e5a60db44..69c499a4a 100644 --- a/src/main/java/com/mindee/parsing/v2/InferenceJob.java +++ b/src/main/java/com/mindee/v2/parsing/inference/InferenceJob.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing.inference; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/InferenceModel.java b/src/main/java/com/mindee/v2/parsing/inference/InferenceModel.java similarity index 94% rename from src/main/java/com/mindee/parsing/v2/InferenceModel.java rename to src/main/java/com/mindee/v2/parsing/inference/InferenceModel.java index bee0eb258..a7ccc9647 100644 --- a/src/main/java/com/mindee/parsing/v2/InferenceModel.java +++ b/src/main/java/com/mindee/v2/parsing/inference/InferenceModel.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing.inference; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/RagMetadata.java b/src/main/java/com/mindee/v2/parsing/inference/RagMetadata.java similarity index 92% rename from src/main/java/com/mindee/parsing/v2/RagMetadata.java rename to src/main/java/com/mindee/v2/parsing/inference/RagMetadata.java index afadb2e3e..3594cd57d 100644 --- a/src/main/java/com/mindee/parsing/v2/RagMetadata.java +++ b/src/main/java/com/mindee/v2/parsing/inference/RagMetadata.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing.inference; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/RawText.java b/src/main/java/com/mindee/v2/parsing/inference/RawText.java similarity index 95% rename from src/main/java/com/mindee/parsing/v2/RawText.java rename to src/main/java/com/mindee/v2/parsing/inference/RawText.java index e8df9ed97..ba3b8953a 100644 --- a/src/main/java/com/mindee/parsing/v2/RawText.java +++ b/src/main/java/com/mindee/v2/parsing/inference/RawText.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing.inference; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/RawTextPage.java b/src/main/java/com/mindee/v2/parsing/inference/RawTextPage.java similarity index 93% rename from src/main/java/com/mindee/parsing/v2/RawTextPage.java rename to src/main/java/com/mindee/v2/parsing/inference/RawTextPage.java index 072bd69fb..a14b2b222 100644 --- a/src/main/java/com/mindee/parsing/v2/RawTextPage.java +++ b/src/main/java/com/mindee/v2/parsing/inference/RawTextPage.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing.inference; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/field/BaseField.java b/src/main/java/com/mindee/v2/parsing/inference/field/BaseField.java similarity index 92% rename from src/main/java/com/mindee/parsing/v2/field/BaseField.java rename to src/main/java/com/mindee/v2/parsing/inference/field/BaseField.java index b7a16ea89..e95ea0be4 100644 --- a/src/main/java/com/mindee/parsing/v2/field/BaseField.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/BaseField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2.field; +package com.mindee.v2.parsing.inference.field; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/field/DynamicField.java b/src/main/java/com/mindee/v2/parsing/inference/field/DynamicField.java similarity index 98% rename from src/main/java/com/mindee/parsing/v2/field/DynamicField.java rename to src/main/java/com/mindee/v2/parsing/inference/field/DynamicField.java index 5ca96bc81..c0966bf0c 100644 --- a/src/main/java/com/mindee/parsing/v2/field/DynamicField.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/DynamicField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2.field; +package com.mindee.v2.parsing.inference.field; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; diff --git a/src/main/java/com/mindee/parsing/v2/field/DynamicFieldDeserializer.java b/src/main/java/com/mindee/v2/parsing/inference/field/DynamicFieldDeserializer.java similarity index 96% rename from src/main/java/com/mindee/parsing/v2/field/DynamicFieldDeserializer.java rename to src/main/java/com/mindee/v2/parsing/inference/field/DynamicFieldDeserializer.java index 9601c1af5..ddd8eb9d1 100644 --- a/src/main/java/com/mindee/parsing/v2/field/DynamicFieldDeserializer.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/DynamicFieldDeserializer.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2.field; +package com.mindee.v2.parsing.inference.field; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.ObjectCodec; diff --git a/src/main/java/com/mindee/parsing/v2/field/FieldConfidence.java b/src/main/java/com/mindee/v2/parsing/inference/field/FieldConfidence.java similarity index 98% rename from src/main/java/com/mindee/parsing/v2/field/FieldConfidence.java rename to src/main/java/com/mindee/v2/parsing/inference/field/FieldConfidence.java index f0e6d7beb..d99ec58d9 100644 --- a/src/main/java/com/mindee/parsing/v2/field/FieldConfidence.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/FieldConfidence.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2.field; +package com.mindee.v2.parsing.inference.field; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/src/main/java/com/mindee/parsing/v2/field/FieldLocation.java b/src/main/java/com/mindee/v2/parsing/inference/field/FieldLocation.java similarity index 85% rename from src/main/java/com/mindee/parsing/v2/field/FieldLocation.java rename to src/main/java/com/mindee/v2/parsing/inference/field/FieldLocation.java index f82c40888..73814e7b1 100644 --- a/src/main/java/com/mindee/parsing/v2/field/FieldLocation.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/FieldLocation.java @@ -1,10 +1,11 @@ -package com.mindee.parsing.v2.field; +package com.mindee.v2.parsing.inference.field; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.mindee.geometry.Polygon; import com.mindee.geometry.PolygonDeserializer; +import com.mindee.geometry.PositionDataField; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -18,7 +19,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @AllArgsConstructor @NoArgsConstructor -public class FieldLocation { +public class FieldLocation implements PositionDataField { /** * Free polygon made up of points. diff --git a/src/main/java/com/mindee/parsing/v2/field/InferenceFields.java b/src/main/java/com/mindee/v2/parsing/inference/field/InferenceFields.java similarity index 98% rename from src/main/java/com/mindee/parsing/v2/field/InferenceFields.java rename to src/main/java/com/mindee/v2/parsing/inference/field/InferenceFields.java index 49bfc508c..025e79d89 100644 --- a/src/main/java/com/mindee/parsing/v2/field/InferenceFields.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/InferenceFields.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2.field; +package com.mindee.v2.parsing.inference.field; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.mindee.parsing.SummaryHelper; diff --git a/src/main/java/com/mindee/parsing/v2/field/ListField.java b/src/main/java/com/mindee/v2/parsing/inference/field/ListField.java similarity index 97% rename from src/main/java/com/mindee/parsing/v2/field/ListField.java rename to src/main/java/com/mindee/v2/parsing/inference/field/ListField.java index c64d92f76..e21030611 100644 --- a/src/main/java/com/mindee/parsing/v2/field/ListField.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/ListField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2.field; +package com.mindee.v2.parsing.inference.field; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/field/ObjectField.java b/src/main/java/com/mindee/v2/parsing/inference/field/ObjectField.java similarity index 99% rename from src/main/java/com/mindee/parsing/v2/field/ObjectField.java rename to src/main/java/com/mindee/v2/parsing/inference/field/ObjectField.java index e3c2a12db..d9cf325b1 100644 --- a/src/main/java/com/mindee/parsing/v2/field/ObjectField.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/ObjectField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2.field; +package com.mindee.v2.parsing.inference.field; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/mindee/parsing/v2/field/SimpleField.java b/src/main/java/com/mindee/v2/parsing/inference/field/SimpleField.java similarity index 98% rename from src/main/java/com/mindee/parsing/v2/field/SimpleField.java rename to src/main/java/com/mindee/v2/parsing/inference/field/SimpleField.java index 84c76c224..1f7d36847 100644 --- a/src/main/java/com/mindee/parsing/v2/field/SimpleField.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/SimpleField.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2.field; +package com.mindee.v2.parsing.inference.field; import static com.mindee.parsing.SummaryHelper.formatForDisplay; diff --git a/src/main/java/com/mindee/parsing/v2/field/SimpleFieldDeserializer.java b/src/main/java/com/mindee/v2/parsing/inference/field/SimpleFieldDeserializer.java similarity index 97% rename from src/main/java/com/mindee/parsing/v2/field/SimpleFieldDeserializer.java rename to src/main/java/com/mindee/v2/parsing/inference/field/SimpleFieldDeserializer.java index 9d2ae2db2..17bfdee62 100644 --- a/src/main/java/com/mindee/parsing/v2/field/SimpleFieldDeserializer.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/SimpleFieldDeserializer.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2.field; +package com.mindee.v2.parsing.inference.field; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.ObjectCodec; diff --git a/src/main/java/com/mindee/v2/product/classification/ClassificationResponse.java b/src/main/java/com/mindee/v2/product/classification/ClassificationResponse.java index e21c33ab5..eba19e4fd 100644 --- a/src/main/java/com/mindee/v2/product/classification/ClassificationResponse.java +++ b/src/main/java/com/mindee/v2/product/classification/ClassificationResponse.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.v2.CommonResponse; import com.mindee.v2.http.ProductInfo; +import com.mindee.v2.parsing.CommonResponse; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/v2/product/crop/CropItem.java b/src/main/java/com/mindee/v2/product/crop/CropItem.java index 1c8c1aa1c..4e998b486 100644 --- a/src/main/java/com/mindee/v2/product/crop/CropItem.java +++ b/src/main/java/com/mindee/v2/product/crop/CropItem.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.v2.field.FieldLocation; +import com.mindee.v2.parsing.inference.field.FieldLocation; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/v2/product/crop/CropResponse.java b/src/main/java/com/mindee/v2/product/crop/CropResponse.java index 7d39b2cb9..0c7a34197 100644 --- a/src/main/java/com/mindee/v2/product/crop/CropResponse.java +++ b/src/main/java/com/mindee/v2/product/crop/CropResponse.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.v2.CommonResponse; import com.mindee.v2.http.ProductInfo; +import com.mindee.v2.parsing.CommonResponse; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/parsing/v2/Inference.java b/src/main/java/com/mindee/v2/product/extraction/ExtractionInference.java similarity index 81% rename from src/main/java/com/mindee/parsing/v2/Inference.java rename to src/main/java/com/mindee/v2/product/extraction/ExtractionInference.java index 6fecd35d9..7a04169a4 100644 --- a/src/main/java/com/mindee/parsing/v2/Inference.java +++ b/src/main/java/com/mindee/v2/product/extraction/ExtractionInference.java @@ -1,8 +1,9 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.product.extraction; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.mindee.v2.parsing.BaseInference; +import com.mindee.v2.parsing.inference.InferenceActiveOptions; import java.util.StringJoiner; import lombok.AllArgsConstructor; import lombok.Getter; @@ -15,7 +16,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @AllArgsConstructor @NoArgsConstructor -public class Inference extends BaseInference { +public class ExtractionInference extends BaseInference { /** * Active options for the inference. */ diff --git a/src/main/java/com/mindee/parsing/v2/InferenceResponse.java b/src/main/java/com/mindee/v2/product/extraction/ExtractionResponse.java similarity index 67% rename from src/main/java/com/mindee/parsing/v2/InferenceResponse.java rename to src/main/java/com/mindee/v2/product/extraction/ExtractionResponse.java index a68de9a4a..a736035fb 100644 --- a/src/main/java/com/mindee/parsing/v2/InferenceResponse.java +++ b/src/main/java/com/mindee/v2/product/extraction/ExtractionResponse.java @@ -1,8 +1,9 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.product.extraction; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.mindee.v2.http.ProductInfo; +import com.mindee.v2.parsing.CommonResponse; import lombok.Getter; /** @@ -11,11 +12,11 @@ @Getter @JsonIgnoreProperties(ignoreUnknown = true) @ProductInfo(slug = "extraction") -public class InferenceResponse extends CommonResponse { +public class ExtractionResponse extends CommonResponse { /** * Inference result. */ @JsonProperty("inference") - private Inference inference; + private ExtractionInference inference; } diff --git a/src/main/java/com/mindee/parsing/v2/InferenceResult.java b/src/main/java/com/mindee/v2/product/extraction/ExtractionResult.java similarity index 81% rename from src/main/java/com/mindee/parsing/v2/InferenceResult.java rename to src/main/java/com/mindee/v2/product/extraction/ExtractionResult.java index c47331cf8..d0709eb70 100644 --- a/src/main/java/com/mindee/parsing/v2/InferenceResult.java +++ b/src/main/java/com/mindee/v2/product/extraction/ExtractionResult.java @@ -1,8 +1,10 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.product.extraction; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.v2.field.InferenceFields; +import com.mindee.v2.parsing.inference.RagMetadata; +import com.mindee.v2.parsing.inference.RawText; +import com.mindee.v2.parsing.inference.field.InferenceFields; import java.util.StringJoiner; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -17,7 +19,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @AllArgsConstructor @NoArgsConstructor -public final class InferenceResult { +public final class ExtractionResult { /** * Extracted fields, the key corresponds to the field's name in the data schema. diff --git a/src/main/java/com/mindee/InferenceParameters.java b/src/main/java/com/mindee/v2/product/extraction/params/ExtractionParameters.java similarity index 91% rename from src/main/java/com/mindee/InferenceParameters.java rename to src/main/java/com/mindee/v2/product/extraction/params/ExtractionParameters.java index 285bda60e..077d8f73c 100644 --- a/src/main/java/com/mindee/InferenceParameters.java +++ b/src/main/java/com/mindee/v2/product/extraction/params/ExtractionParameters.java @@ -1,5 +1,6 @@ -package com.mindee; +package com.mindee.v2.product.extraction.params; +import com.mindee.AsyncPollingOptions; import com.mindee.v2.clientOptions.BaseParameters; import com.mindee.v2.http.ProductInfo; import lombok.EqualsAndHashCode; @@ -12,7 +13,7 @@ @Getter @EqualsAndHashCode(callSuper = true) @ProductInfo(slug = "extraction") -public final class InferenceParameters extends BaseParameters { +public final class ExtractionParameters extends BaseParameters { /** * Enhance extraction accuracy with Retrieval-Augmented Generation. */ @@ -40,7 +41,7 @@ public final class InferenceParameters extends BaseParameters { */ private final String dataSchema; - private InferenceParameters( + private ExtractionParameters( String modelId, String alias, String[] webhookIds, @@ -95,7 +96,7 @@ public static Builder builder(String modelId) { } /** - * Fluent builder for {@link InferenceParameters}. + * Fluent builder for {@link ExtractionParameters}. */ public static final class Builder extends BaseParameters.BaseBuilder { private Boolean rag = null; @@ -148,9 +149,9 @@ public Builder dataSchema(String dataSchema) { return this; } - /** Build an immutable {@link InferenceParameters} instance. */ - public InferenceParameters build() { - return new InferenceParameters( + /** Build an immutable {@link ExtractionParameters} instance. */ + public ExtractionParameters build() { + return new ExtractionParameters( modelId, alias, webhookIds, diff --git a/src/main/java/com/mindee/v2/product/ocr/OcrResponse.java b/src/main/java/com/mindee/v2/product/ocr/OcrResponse.java index 36dc333a6..d5dfea6fc 100644 --- a/src/main/java/com/mindee/v2/product/ocr/OcrResponse.java +++ b/src/main/java/com/mindee/v2/product/ocr/OcrResponse.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.v2.CommonResponse; import com.mindee.v2.http.ProductInfo; +import com.mindee.v2.parsing.CommonResponse; import lombok.Getter; /** diff --git a/src/main/java/com/mindee/v2/product/split/SplitResponse.java b/src/main/java/com/mindee/v2/product/split/SplitResponse.java index 248612323..504ede8c7 100644 --- a/src/main/java/com/mindee/v2/product/split/SplitResponse.java +++ b/src/main/java/com/mindee/v2/product/split/SplitResponse.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.v2.CommonResponse; import com.mindee.v2.http.ProductInfo; +import com.mindee.v2.parsing.CommonResponse; import lombok.Getter; /** diff --git a/src/test/java/com/mindee/geometry/PolygonUtilsTest.java b/src/test/java/com/mindee/geometry/PolygonUtilsTest.java index 6829c962b..4b489569e 100644 --- a/src/test/java/com/mindee/geometry/PolygonUtilsTest.java +++ b/src/test/java/com/mindee/geometry/PolygonUtilsTest.java @@ -9,56 +9,36 @@ public class PolygonUtilsTest { @Test public void givenAValidPolygonMustGetTheValidCentroid() { - // given - Polygon polygonWichIsNotRectangle = PolygonSample.getPolygonAsRectangle(); - - // then - Point centroid = polygonWichIsNotRectangle.getCentroid(); - + Polygon nonRectangularPolygon = PolygonSample.getPolygonAsRectangle(); + Point centroid = nonRectangularPolygon.getCentroid(); Assertions.assertEquals(new Point(0.149, 0.538), centroid); } @Test public void givenAValidPolygonMustGetTheMaxX() { - // given - Polygon polygonWichIsNotRectangle = PolygonSample.getPolygonAsRectangle(); - - // then - Double maxX = PolygonUtils.getMaxXCoordinate(polygonWichIsNotRectangle); - + Polygon nonRectangularPolygon = PolygonSample.getPolygonAsRectangle(); + Double maxX = nonRectangularPolygon.getMinMaxX().getMax(); Assertions.assertEquals(0.175, maxX); } @Test public void givenAValidPolygonMustGetTheMinX() { - // given - Polygon polygonWichIsNotRectangle = PolygonSample.getPolygonAsRectangle(); - - // then - Double minX = PolygonUtils.getMinXCoordinate(polygonWichIsNotRectangle); - + Polygon nonRectangularPolygon = PolygonSample.getPolygonAsRectangle(); + Double minX = nonRectangularPolygon.getMinMaxX().getMin(); Assertions.assertEquals(0.123, minX); } @Test public void givenAValidPolygonMustGetTheMaxY() { - // given - Polygon polygonWichIsNotRectangle = PolygonSample.getPolygonAsRectangle(); - - // then - Double maxY = PolygonUtils.getMaxYCoordinate(polygonWichIsNotRectangle); - + Polygon nonRectangularPolygon = PolygonSample.getPolygonAsRectangle(); + Double maxY = nonRectangularPolygon.getMinMaxY().getMax(); Assertions.assertEquals(0.546, maxY); } @Test public void givenAValidPolygonMustGetTheMinY() { - // given - Polygon polygonWichIsNotRectangle = PolygonSample.getPolygonAsRectangle(); - - // then - Double minY = PolygonUtils.getMinYCoordinate(polygonWichIsNotRectangle); - + Polygon nonRectangularPolygon = PolygonSample.getPolygonAsRectangle(); + Double minY = nonRectangularPolygon.getMinMaxY().getMin(); Assertions.assertEquals(0.53, minY); } @@ -86,12 +66,12 @@ public void combinePolygonsWithTwoNotNullMustGetAValidPolygon() { ); // then - Polygon mergedPolygon = PolygonUtils.combine(polygon1, polygon2); + Polygon mergedPolygon = polygon1.combine(polygon2); - Assertions.assertEquals(0.442, PolygonUtils.getMinYCoordinate(mergedPolygon)); - Assertions.assertEquals(0.081, PolygonUtils.getMinXCoordinate(mergedPolygon)); - Assertions.assertEquals(0.451, PolygonUtils.getMaxYCoordinate(mergedPolygon)); - Assertions.assertEquals(0.26, PolygonUtils.getMaxXCoordinate(mergedPolygon)); + Assertions.assertEquals(0.081, mergedPolygon.getMinMaxX().getMin()); + Assertions.assertEquals(0.26, mergedPolygon.getMinMaxX().getMax()); + Assertions.assertEquals(0.442, mergedPolygon.getMinMaxY().getMin()); + Assertions.assertEquals(0.451, mergedPolygon.getMinMaxY().getMax()); } @Test @@ -99,12 +79,10 @@ public void combineWithNullPolygonMustThrow() { assertThrows(IllegalStateException.class, () -> { Polygon polygon = PolygonUtils.combine(null, null); }); - } @Test public void combineWith1PolygonAndANullPolygonMustGetNull() { - // given Polygon polygon1 = new Polygon( Arrays .asList( @@ -115,15 +93,12 @@ public void combineWith1PolygonAndANullPolygonMustGetNull() { ) ); - Polygon polygon2 = null; - - // then - Polygon mergedPolygon = PolygonUtils.combine(polygon1, polygon2); + Polygon mergedPolygon = polygon1.combine(null); - Assertions.assertEquals(0.442, PolygonUtils.getMinYCoordinate(mergedPolygon)); - Assertions.assertEquals(0.081, PolygonUtils.getMinXCoordinate(mergedPolygon)); - Assertions.assertEquals(0.451, PolygonUtils.getMaxYCoordinate(mergedPolygon)); - Assertions.assertEquals(0.15, PolygonUtils.getMaxXCoordinate(mergedPolygon)); + Assertions.assertEquals(0.081, mergedPolygon.getMinMaxX().getMin()); + Assertions.assertEquals(0.15, mergedPolygon.getMinMaxX().getMax()); + Assertions.assertEquals(0.442, mergedPolygon.getMinMaxY().getMin()); + Assertions.assertEquals(0.451, mergedPolygon.getMinMaxY().getMax()); } } diff --git a/src/test/java/com/mindee/http/MindeeHttpApiTest.java b/src/test/java/com/mindee/http/MindeeHttpApiV1Test.java similarity index 88% rename from src/test/java/com/mindee/http/MindeeHttpApiTest.java rename to src/test/java/com/mindee/http/MindeeHttpApiV1Test.java index e933d50e2..036545bcd 100644 --- a/src/test/java/com/mindee/http/MindeeHttpApiTest.java +++ b/src/test/java/com/mindee/http/MindeeHttpApiV1Test.java @@ -13,13 +13,17 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.junit.WireMockRule; -import com.mindee.MindeeSettings; -import com.mindee.PredictOptions; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.invoice.InvoiceV4; -import com.mindee.product.invoicesplitter.InvoiceSplitterV1; +import com.mindee.v1.MindeeSettings; +import com.mindee.v1.clientOptions.PredictOptions; +import com.mindee.v1.http.Endpoint; +import com.mindee.v1.http.MindeeHttpApiV1; +import com.mindee.v1.http.MindeeHttpExceptionV1; +import com.mindee.v1.http.RequestParameters; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.invoice.InvoiceV4; +import com.mindee.v1.product.invoicesplitter.InvoiceSplitterV1; import java.io.File; import java.io.IOException; import java.net.URL; @@ -42,7 +46,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class MindeeHttpApiTest { +public class MindeeHttpApiV1Test { MockWebServer mockWebServer = new MockWebServer(); private static final ObjectMapper objectMapper = new ObjectMapper(); @@ -57,7 +61,7 @@ public void stopWebServer() throws Exception { mockWebServer.shutdown(); } - private MindeeHttpApi getClientForResponse(Path filePath, int statusCode) throws IOException { + private MindeeHttpApiV1 getClientForResponse(Path filePath, int statusCode) throws IOException { String url = String.format("http://localhost:%s", mockWebServer.getPort()); mockWebServer .enqueue( @@ -67,20 +71,23 @@ private MindeeHttpApi getClientForResponse(Path filePath, int statusCode) throws ); HttpClientBuilder httpClientBuilder = HttpClients.custom().disableAutomaticRetries(); - return MindeeHttpApi + return MindeeHttpApiV1 .builder() .mindeeSettings(new MindeeSettings("abc", url)) .httpClientBuilder(httpClientBuilder) .build(); } - private MindeeHttpApi getClientForResponse(String filePath, int statusCode) throws IOException { + private MindeeHttpApiV1 getClientForResponse(String filePath, int statusCode) throws IOException { return getClientForResponse(getV1ResourcePath(filePath), statusCode); } @Test void givenAResponseFromTheEndpoint_whenDeserialized_mustHaveValidSummary() throws IOException { - MindeeHttpApi client = getClientForResponse("products/invoices/response_v4/complete.json", 200); + MindeeHttpApiV1 client = getClientForResponse( + "products/invoices/response_v4/complete.json", + 200 + ); Path filePath = getV1ResourcePath("products/invoices/invoice.pdf"); @@ -110,7 +117,10 @@ void givenAResponseFromTheEndpoint_whenDeserialized_mustHaveValidSummary() throw @Test void givenParseParametersWithFile_whenParsed_shouldBuildRequestCorrectly() throws IOException, InterruptedException { - MindeeHttpApi client = getClientForResponse("products/invoices/response_v4/complete.json", 200); + MindeeHttpApiV1 client = getClientForResponse( + "products/invoices/response_v4/complete.json", + 200 + ); Path filePath = getV1ResourcePath("products/invoices/invoice.pdf"); byte[] fileBytes = Files.readAllBytes(filePath); Document document = client @@ -137,7 +147,10 @@ void givenParseParametersWithFile_whenParsed_shouldBuildRequestCorrectly() throw @Test void givenPredictOptions_whenParsed_shouldBuildRequestCorrectly() throws IOException, InterruptedException { - MindeeHttpApi client = getClientForResponse("products/invoices/response_v4/complete.json", 200); + MindeeHttpApiV1 client = getClientForResponse( + "products/invoices/response_v4/complete.json", + 200 + ); Path filePath = getV1ResourcePath("products/invoices/invoice.pdf"); byte[] fileBytes = Files.readAllBytes(filePath); PredictOptions predictOptions = PredictOptions.builder().cropper(true).allWords(true).build(); @@ -169,7 +182,10 @@ void givenPredictOptions_whenParsed_shouldBuildRequestCorrectly() throws IOExcep @Test void givenParseParametersWithFileUrl_whenParsed_shouldBuildRequestCorrectly() throws IOException, InterruptedException { - MindeeHttpApi client = getClientForResponse("products/invoices/response_v4/complete.json", 200); + MindeeHttpApiV1 client = getClientForResponse( + "products/invoices/response_v4/complete.json", + 200 + ); Document document = client .predictPost( @@ -216,7 +232,7 @@ void givenAnUrlBuilderFunction_whenParsed_callsTheCorrectUrl() throws IOExceptio HttpClientBuilder httpClientBuilder = HttpClients.custom().disableAutomaticRetries(); - MindeeHttpApi client = MindeeHttpApi + MindeeHttpApiV1 client = MindeeHttpApiV1 .builder() .mindeeSettings(new MindeeSettings("abc", url)) .httpClientBuilder(httpClientBuilder) @@ -272,7 +288,7 @@ void givenAHttpClientBuilder_whenParseCalled_usesClientBuilderToMakeHttpClient() .setRoutePlanner(routePlanner) .disableAutomaticRetries(); - MindeeHttpApi client = MindeeHttpApi + MindeeHttpApiV1 client = MindeeHttpApiV1 .builder() .mindeeSettings(new MindeeSettings("abc", url)) .httpClientBuilder(httpClientBuilder) @@ -311,7 +327,7 @@ void givenAHttpClientBuilder_whenParseCalled_usesClientBuilderToMakeHttpClient() @Test void givenAnAsncResponse_whenDeserialized_mustHaveValidJob() throws IOException, InterruptedException { Path path = getV1ResourcePath("async/post_success.json"); - MindeeHttpApi client = getClientForResponse(path, 200); + MindeeHttpApiV1 client = getClientForResponse(path, 200); File file = new File(getV1ResourcePathString("products/invoices/invoice.pdf")); AsyncPredictResponse response = client @@ -342,7 +358,7 @@ void givenAnAsncResponse_whenDeserialized_mustHaveValidJob() throws IOException, @Test void givenAResponseFromTheJobEndpoint_whenDeserialized_mustHaveValidJobAndDocument() throws IOException, InterruptedException { Path path = getV1ResourcePath("async/get_completed.json"); - MindeeHttpApi client = getClientForResponse(path, 200); + MindeeHttpApiV1 client = getClientForResponse(path, 200); AsyncPredictResponse response = client .documentQueueGet( @@ -370,7 +386,7 @@ void givenAResponseFromTheJobEndpoint_whenDeserialized_mustHaveValidJobAndDocume @Test void givenError401_noToken_mustThrowMindeeHttpException() throws IOException { - MindeeHttpApi client = getClientForResponse("errors/error_401_no_token.json", 401); + MindeeHttpApiV1 client = getClientForResponse("errors/error_401_no_token.json", 401); File file = new File(getV1ResourcePathString("products/invoices/invoice.pdf")); byte[] fileInBytes = Files.readAllBytes(file.toPath()); @@ -380,9 +396,9 @@ void givenError401_noToken_mustThrowMindeeHttpException() throws IOException { .fileName(file.getName()) .build(); - MindeeHttpException httpError = Assertions + MindeeHttpExceptionV1 httpError = Assertions .assertThrows( - MindeeHttpException.class, + MindeeHttpExceptionV1.class, () -> client.predictPost(InvoiceV4.class, new Endpoint(InvoiceV4.class), parseParameter) ); Assertions.assertEquals(401, httpError.getStatusCode()); @@ -392,7 +408,7 @@ void givenError401_noToken_mustThrowMindeeHttpException() throws IOException { @Test void givenError429_mustThrowMindeeHttpException() throws IOException { - MindeeHttpApi client = getClientForResponse("errors/error_429_too_many_requests.json", 429); + MindeeHttpApiV1 client = getClientForResponse("errors/error_429_too_many_requests.json", 429); File file = new File(getV1ResourcePathString("products/invoices/invoice.pdf")); byte[] fileInBytes = Files.readAllBytes(file.toPath()); @@ -402,9 +418,9 @@ void givenError429_mustThrowMindeeHttpException() throws IOException { .fileName(file.getName()) .build(); - MindeeHttpException httpError = Assertions + MindeeHttpExceptionV1 httpError = Assertions .assertThrows( - MindeeHttpException.class, + MindeeHttpExceptionV1.class, () -> client.predictPost(InvoiceV4.class, new Endpoint(InvoiceV4.class), parseParameter) ); Assertions.assertEquals(429, httpError.getStatusCode()); @@ -415,7 +431,7 @@ void givenError429_mustThrowMindeeHttpException() throws IOException { @Test void givenError_inHtml_mustThrowMindeeHttpException() throws IOException { - MindeeHttpApi client = getClientForResponse("errors/error_50x.html", 413); + MindeeHttpApiV1 client = getClientForResponse("errors/error_50x.html", 413); Path filePath = getV1ResourcePath("products/invoices/invoice.pdf"); byte[] fileBytes = Files.readAllBytes(filePath); @@ -425,9 +441,9 @@ void givenError_inHtml_mustThrowMindeeHttpException() throws IOException { .fileName(filePath.getFileName().toString()) .build(); - MindeeHttpException httpError = Assertions + MindeeHttpExceptionV1 httpError = Assertions .assertThrows( - MindeeHttpException.class, + MindeeHttpExceptionV1.class, () -> client.predictPost(InvoiceV4.class, new Endpoint(InvoiceV4.class), parseParameter) ); Assertions.assertEquals(413, httpError.getStatusCode()); @@ -442,7 +458,7 @@ void givenError_inHtml_mustThrowMindeeHttpException() throws IOException { @Test void givenError400_noDetails_mustThrowMindeeHttpException() throws IOException { - MindeeHttpApi client = getClientForResponse("errors/error_400_no_details.json", 400); + MindeeHttpApiV1 client = getClientForResponse("errors/error_400_no_details.json", 400); Path filePath = getV1ResourcePath("products/invoices/invoice.pdf"); byte[] fileBytes = Files.readAllBytes(filePath); @@ -452,9 +468,9 @@ void givenError400_noDetails_mustThrowMindeeHttpException() throws IOException { .fileName(filePath.getFileName().toString()) .build(); - MindeeHttpException httpError = Assertions + MindeeHttpExceptionV1 httpError = Assertions .assertThrows( - MindeeHttpException.class, + MindeeHttpExceptionV1.class, () -> client.predictPost(InvoiceV4.class, new Endpoint(InvoiceV4.class), parseParameter) ); Assertions.assertEquals(400, httpError.getStatusCode()); diff --git a/src/test/java/com/mindee/extraction/ImageExtractorTest.java b/src/test/java/com/mindee/image/ImageExtractorTest.java similarity index 93% rename from src/test/java/com/mindee/extraction/ImageExtractorTest.java rename to src/test/java/com/mindee/image/ImageExtractorTest.java index d5798c265..cff2fa79f 100644 --- a/src/test/java/com/mindee/extraction/ImageExtractorTest.java +++ b/src/test/java/com/mindee/image/ImageExtractorTest.java @@ -1,4 +1,4 @@ -package com.mindee.extraction; +package com.mindee.image; import static com.mindee.TestingUtilities.getResourcePath; import static com.mindee.TestingUtilities.getV1ResourcePath; @@ -7,12 +7,12 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.Page; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.barcodereader.BarcodeReaderV1; -import com.mindee.product.barcodereader.BarcodeReaderV1Document; -import com.mindee.product.multireceiptsdetector.MultiReceiptsDetectorV1; -import com.mindee.product.multireceiptsdetector.MultiReceiptsDetectorV1Document; +import com.mindee.v1.parsing.common.Page; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.barcodereader.BarcodeReaderV1; +import com.mindee.v1.product.barcodereader.BarcodeReaderV1Document; +import com.mindee.v1.product.multireceiptsdetector.MultiReceiptsDetectorV1; +import com.mindee.v1.product.multireceiptsdetector.MultiReceiptsDetectorV1Document; import java.io.IOException; import java.util.List; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/input/LocalResponseV2Test.java b/src/test/java/com/mindee/input/LocalResponseV2Test.java index d7066df9d..5213d31aa 100644 --- a/src/test/java/com/mindee/input/LocalResponseV2Test.java +++ b/src/test/java/com/mindee/input/LocalResponseV2Test.java @@ -2,7 +2,7 @@ import static com.mindee.TestingUtilities.getV2ResourcePath; -import com.mindee.parsing.v2.InferenceResponse; +import com.mindee.v2.product.extraction.ExtractionResponse; import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -34,7 +34,7 @@ protected void assertLocalResponse(LocalResponse localResponse) { ); Assertions.assertEquals(this.signature, localResponse.getHmacSignature(this.secretKey)); Assertions.assertTrue(localResponse.isValidHmacSignature(this.secretKey, this.signature)); - InferenceResponse response = localResponse.deserializeResponse(InferenceResponse.class); + ExtractionResponse response = localResponse.deserializeResponse(ExtractionResponse.class); Assertions.assertNotNull(response); Assertions.assertNotNull(response.getInference()); } diff --git a/src/test/java/com/mindee/input/URLInputSourceIT.java b/src/test/java/com/mindee/input/URLInputSourceIT.java index 44bd772e1..577ae483a 100644 --- a/src/test/java/com/mindee/input/URLInputSourceIT.java +++ b/src/test/java/com/mindee/input/URLInputSourceIT.java @@ -3,9 +3,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.mindee.MindeeClient; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.invoice.InvoiceV4; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.invoice.InvoiceV4; import java.io.IOException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/mindee/extraction/PDFExtractorTest.java b/src/test/java/com/mindee/pdf/PDFExtractorTest.java similarity index 95% rename from src/test/java/com/mindee/extraction/PDFExtractorTest.java rename to src/test/java/com/mindee/pdf/PDFExtractorTest.java index bfdaaaf8c..aa4810349 100644 --- a/src/test/java/com/mindee/extraction/PDFExtractorTest.java +++ b/src/test/java/com/mindee/pdf/PDFExtractorTest.java @@ -1,12 +1,12 @@ -package com.mindee.extraction; +package com.mindee.pdf; import static com.mindee.TestingUtilities.getV1ResourcePath; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.invoicesplitter.InvoiceSplitterV1; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.invoicesplitter.InvoiceSplitterV1; import java.io.IOException; import java.util.List; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/MindeeClientTest.java b/src/test/java/com/mindee/v1/MindeeClientTest.java similarity index 95% rename from src/test/java/com/mindee/MindeeClientTest.java rename to src/test/java/com/mindee/v1/MindeeClientTest.java index 7ec009b5c..0136fb7fc 100644 --- a/src/test/java/com/mindee/MindeeClientTest.java +++ b/src/test/java/com/mindee/v1/MindeeClientTest.java @@ -1,25 +1,26 @@ -package com.mindee; +package com.mindee.v1; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getResourcePath; import static com.mindee.TestingUtilities.getV1ResourcePathString; -import com.mindee.http.Endpoint; -import com.mindee.http.MindeeApi; -import com.mindee.http.RequestParameters; import com.mindee.input.LocalInputSource; import com.mindee.input.LocalResponse; import com.mindee.input.PageOptions; import com.mindee.input.PageOptionsOperation; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.Job; -import com.mindee.parsing.common.PredictResponse; import com.mindee.pdf.PdfOperation; import com.mindee.pdf.SplitPdf; -import com.mindee.product.generated.GeneratedV1; -import com.mindee.product.internationalid.InternationalIdV2; -import com.mindee.product.invoice.InvoiceV4; +import com.mindee.v1.clientOptions.PredictOptions; +import com.mindee.v1.http.Endpoint; +import com.mindee.v1.http.MindeeApiV1; +import com.mindee.v1.http.RequestParameters; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.Job; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.generated.GeneratedV1; +import com.mindee.v1.product.internationalid.InternationalIdV2; +import com.mindee.v1.product.invoice.InvoiceV4; import java.io.File; import java.io.IOException; import java.net.URL; @@ -39,12 +40,12 @@ class MindeeClientTest { MindeeClient client; - MindeeApi mindeeApi; + MindeeApiV1 mindeeApi; PdfOperation pdfOperation; @BeforeEach public void setUp() { - mindeeApi = Mockito.mock(MindeeApi.class); + mindeeApi = Mockito.mock(MindeeApiV1.class); pdfOperation = Mockito.mock(PdfOperation.class); client = new MindeeClient(pdfOperation, mindeeApi); } diff --git a/src/test/java/com/mindee/MindeeSettingsTest.java b/src/test/java/com/mindee/v1/MindeeSettingsTest.java similarity index 96% rename from src/test/java/com/mindee/MindeeSettingsTest.java rename to src/test/java/com/mindee/v1/MindeeSettingsTest.java index 46f76d69d..80e81df9c 100644 --- a/src/test/java/com/mindee/MindeeSettingsTest.java +++ b/src/test/java/com/mindee/v1/MindeeSettingsTest.java @@ -1,4 +1,4 @@ -package com.mindee; +package com.mindee.v1; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/mindee/extraction/InvoiceSplitterAutoExtractionIT.java b/src/test/java/com/mindee/v1/fileOperation/InvoiceSplitterAutoExtractionIT.java similarity index 90% rename from src/test/java/com/mindee/extraction/InvoiceSplitterAutoExtractionIT.java rename to src/test/java/com/mindee/v1/fileOperation/InvoiceSplitterAutoExtractionIT.java index e4d80c16b..982efc911 100644 --- a/src/test/java/com/mindee/extraction/InvoiceSplitterAutoExtractionIT.java +++ b/src/test/java/com/mindee/v1/fileOperation/InvoiceSplitterAutoExtractionIT.java @@ -1,17 +1,19 @@ -package com.mindee.extraction; +package com.mindee.v1.fileOperation; import static com.mindee.TestingUtilities.getV1ResourcePath; import static com.mindee.TestingUtilities.levenshteinRatio; -import com.mindee.MindeeClient; import com.mindee.MindeeException; import com.mindee.TestingUtilities; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.invoice.InvoiceV4; -import com.mindee.product.invoicesplitter.InvoiceSplitterV1; +import com.mindee.pdf.ExtractedPDF; +import com.mindee.pdf.PDFExtractor; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.product.invoice.InvoiceV4; +import com.mindee.v1.product.invoicesplitter.InvoiceSplitterV1; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; diff --git a/src/test/java/com/mindee/parsing/common/AsyncPredictResponseTest.java b/src/test/java/com/mindee/v1/parsing/common/AsyncPredictResponseTest.java similarity index 97% rename from src/test/java/com/mindee/parsing/common/AsyncPredictResponseTest.java rename to src/test/java/com/mindee/v1/parsing/common/AsyncPredictResponseTest.java index 83d1e5701..df3b20c96 100644 --- a/src/test/java/com/mindee/parsing/common/AsyncPredictResponseTest.java +++ b/src/test/java/com/mindee/v1/parsing/common/AsyncPredictResponseTest.java @@ -1,11 +1,11 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import static com.mindee.TestingUtilities.getV1ResourcePath; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.product.invoicesplitter.InvoiceSplitterV1; +import com.mindee.v1.product.invoicesplitter.InvoiceSplitterV1; import java.io.IOException; import java.nio.file.Path; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/parsing/common/CropperTest.java b/src/test/java/com/mindee/v1/parsing/common/CropperTest.java similarity index 85% rename from src/test/java/com/mindee/parsing/common/CropperTest.java rename to src/test/java/com/mindee/v1/parsing/common/CropperTest.java index 48a553bf4..ddfe4f592 100644 --- a/src/test/java/com/mindee/parsing/common/CropperTest.java +++ b/src/test/java/com/mindee/v1/parsing/common/CropperTest.java @@ -1,12 +1,12 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import static com.mindee.TestingUtilities.getV1ResourcePath; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.standard.PositionField; -import com.mindee.product.receipt.ReceiptV5; -import com.mindee.product.receipt.ReceiptV5Document; +import com.mindee.v1.parsing.standard.PositionField; +import com.mindee.v1.product.receipt.ReceiptV5; +import com.mindee.v1.product.receipt.ReceiptV5Document; import java.io.IOException; import java.util.List; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/parsing/common/ErrorTest.java b/src/test/java/com/mindee/v1/parsing/common/ErrorTest.java similarity index 85% rename from src/test/java/com/mindee/parsing/common/ErrorTest.java rename to src/test/java/com/mindee/v1/parsing/common/ErrorTest.java index 16915947e..b4cd1ccbd 100644 --- a/src/test/java/com/mindee/parsing/common/ErrorTest.java +++ b/src/test/java/com/mindee/v1/parsing/common/ErrorTest.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import static com.mindee.TestingUtilities.getV1ResourcePath; @@ -15,10 +15,10 @@ void given_details_as_object_mustBeDeserialized() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.findAndRegisterModules(); - Error error = objectMapper + com.mindee.v1.parsing.common.Error error = objectMapper .readValue( getV1ResourcePath("errors/with_object_response_in_detail.json").toFile(), - Error.class + com.mindee.v1.parsing.common.Error.class ); Assertions.assertNotNull(error); @@ -32,7 +32,7 @@ void given_details_as_string_mustBeDeserialized() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.findAndRegisterModules(); - Error error = objectMapper + com.mindee.v1.parsing.common.Error error = objectMapper .readValue( getV1ResourcePath("errors/with_string_response_in_detail.json").toFile(), Error.class diff --git a/src/test/java/com/mindee/parsing/common/FullTextOcrTest.java b/src/test/java/com/mindee/v1/parsing/common/FullTextOcrTest.java similarity index 92% rename from src/test/java/com/mindee/parsing/common/FullTextOcrTest.java rename to src/test/java/com/mindee/v1/parsing/common/FullTextOcrTest.java index cf8d1f24e..227811733 100644 --- a/src/test/java/com/mindee/parsing/common/FullTextOcrTest.java +++ b/src/test/java/com/mindee/v1/parsing/common/FullTextOcrTest.java @@ -1,11 +1,11 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import static com.mindee.TestingUtilities.getV1ResourcePath; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.product.internationalid.InternationalIdV2; -import com.mindee.product.internationalid.InternationalIdV2Document; +import com.mindee.v1.product.internationalid.InternationalIdV2; +import com.mindee.v1.product.internationalid.InternationalIdV2Document; import java.io.IOException; import java.nio.file.Files; import java.util.List; diff --git a/src/test/java/com/mindee/parsing/common/OcrTest.java b/src/test/java/com/mindee/v1/parsing/common/OcrTest.java similarity index 91% rename from src/test/java/com/mindee/parsing/common/OcrTest.java rename to src/test/java/com/mindee/v1/parsing/common/OcrTest.java index ea21a0e90..cc31a58b5 100644 --- a/src/test/java/com/mindee/parsing/common/OcrTest.java +++ b/src/test/java/com/mindee/v1/parsing/common/OcrTest.java @@ -1,12 +1,12 @@ -package com.mindee.parsing.common; +package com.mindee.v1.parsing.common; import static com.mindee.TestingUtilities.getV1ResourcePath; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.ocr.Ocr; -import com.mindee.parsing.common.ocr.Word; -import com.mindee.product.receipt.ReceiptV5; +import com.mindee.v1.parsing.common.ocr.Ocr; +import com.mindee.v1.parsing.common.ocr.Word; +import com.mindee.v1.product.receipt.ReceiptV5; import java.io.IOException; import java.nio.file.Files; import java.util.List; diff --git a/src/test/java/com/mindee/parsing/standard/DateFieldTest.java b/src/test/java/com/mindee/v1/parsing/standard/DateFieldTest.java similarity index 94% rename from src/test/java/com/mindee/parsing/standard/DateFieldTest.java rename to src/test/java/com/mindee/v1/parsing/standard/DateFieldTest.java index ec2667a84..1389ea0d6 100644 --- a/src/test/java/com/mindee/parsing/standard/DateFieldTest.java +++ b/src/test/java/com/mindee/v1/parsing/standard/DateFieldTest.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.standard; +package com.mindee.v1.parsing.standard; import com.mindee.geometry.Point; import com.mindee.geometry.Polygon; diff --git a/src/test/java/com/mindee/product/barcodereader/BarcodeReaderV1Test.java b/src/test/java/com/mindee/v1/product/barcodereader/BarcodeReaderV1Test.java similarity index 92% rename from src/test/java/com/mindee/product/barcodereader/BarcodeReaderV1Test.java rename to src/test/java/com/mindee/v1/product/barcodereader/BarcodeReaderV1Test.java index 794481672..d92f10193 100644 --- a/src/test/java/com/mindee/product/barcodereader/BarcodeReaderV1Test.java +++ b/src/test/java/com/mindee/v1/product/barcodereader/BarcodeReaderV1Test.java @@ -1,12 +1,12 @@ -package com.mindee.product.barcodereader; +package com.mindee.v1.product.barcodereader; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/cropper/CropperV1Test.java b/src/test/java/com/mindee/v1/product/cropper/CropperV1Test.java similarity index 91% rename from src/test/java/com/mindee/product/cropper/CropperV1Test.java rename to src/test/java/com/mindee/v1/product/cropper/CropperV1Test.java index d6a8a7b31..881c8f348 100644 --- a/src/test/java/com/mindee/product/cropper/CropperV1Test.java +++ b/src/test/java/com/mindee/v1/product/cropper/CropperV1Test.java @@ -1,13 +1,13 @@ -package com.mindee.product.cropper; +package com.mindee.v1.product.cropper; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.Page; -import com.mindee.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.Page; +import com.mindee.v1.parsing.common.PredictResponse; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/driverlicense/DriverLicenseV1Test.java b/src/test/java/com/mindee/v1/product/driverlicense/DriverLicenseV1Test.java similarity index 94% rename from src/test/java/com/mindee/product/driverlicense/DriverLicenseV1Test.java rename to src/test/java/com/mindee/v1/product/driverlicense/DriverLicenseV1Test.java index 97c2b14ac..a219ce099 100644 --- a/src/test/java/com/mindee/product/driverlicense/DriverLicenseV1Test.java +++ b/src/test/java/com/mindee/v1/product/driverlicense/DriverLicenseV1Test.java @@ -1,12 +1,12 @@ -package com.mindee.product.driverlicense; +package com.mindee.v1.product.driverlicense; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/financialdocument/FinancialDocumentV1Test.java b/src/test/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1Test.java similarity index 98% rename from src/test/java/com/mindee/product/financialdocument/FinancialDocumentV1Test.java rename to src/test/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1Test.java index 87eb7df0f..1bf75781b 100644 --- a/src/test/java/com/mindee/product/financialdocument/FinancialDocumentV1Test.java +++ b/src/test/java/com/mindee/v1/product/financialdocument/FinancialDocumentV1Test.java @@ -1,12 +1,12 @@ -package com.mindee.product.financialdocument; +package com.mindee.v1.product.financialdocument; import static com.mindee.TestingUtilities.getV1ResourcePath; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; import java.io.File; import java.io.IOException; import java.nio.file.Files; diff --git a/src/test/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Test.java b/src/test/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2Test.java similarity index 93% rename from src/test/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Test.java rename to src/test/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2Test.java index 7b73f8df2..b75e93764 100644 --- a/src/test/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Test.java +++ b/src/test/java/com/mindee/v1/product/fr/bankaccountdetails/BankAccountDetailsV2Test.java @@ -1,12 +1,12 @@ -package com.mindee.product.fr.bankaccountdetails; +package com.mindee.v1.product.fr.bankaccountdetails; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/fr/cartegrise/CarteGriseV1Test.java b/src/test/java/com/mindee/v1/product/fr/cartegrise/CarteGriseV1Test.java similarity index 96% rename from src/test/java/com/mindee/product/fr/cartegrise/CarteGriseV1Test.java rename to src/test/java/com/mindee/v1/product/fr/cartegrise/CarteGriseV1Test.java index 146477982..3121e6b70 100644 --- a/src/test/java/com/mindee/product/fr/cartegrise/CarteGriseV1Test.java +++ b/src/test/java/com/mindee/v1/product/fr/cartegrise/CarteGriseV1Test.java @@ -1,12 +1,12 @@ -package com.mindee.product.fr.cartegrise; +package com.mindee.v1.product.fr.cartegrise; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/fr/idcard/IdCardV1Test.java b/src/test/java/com/mindee/v1/product/fr/idcard/IdCardV1Test.java similarity index 92% rename from src/test/java/com/mindee/product/fr/idcard/IdCardV1Test.java rename to src/test/java/com/mindee/v1/product/fr/idcard/IdCardV1Test.java index 5669371e7..d34aa9197 100644 --- a/src/test/java/com/mindee/product/fr/idcard/IdCardV1Test.java +++ b/src/test/java/com/mindee/v1/product/fr/idcard/IdCardV1Test.java @@ -1,14 +1,14 @@ -package com.mindee.product.fr.idcard; +package com.mindee.v1.product.fr.idcard; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.Page; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.Page; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.standard.ClassificationField; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/fr/idcard/IdCardV2Test.java b/src/test/java/com/mindee/v1/product/fr/idcard/IdCardV2Test.java similarity index 93% rename from src/test/java/com/mindee/product/fr/idcard/IdCardV2Test.java rename to src/test/java/com/mindee/v1/product/fr/idcard/IdCardV2Test.java index a03abb0ac..905947f2a 100644 --- a/src/test/java/com/mindee/product/fr/idcard/IdCardV2Test.java +++ b/src/test/java/com/mindee/v1/product/fr/idcard/IdCardV2Test.java @@ -1,14 +1,14 @@ -package com.mindee.product.fr.idcard; +package com.mindee.v1.product.fr.idcard; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.Page; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.Page; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.standard.ClassificationField; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/generated/GeneratedV1Test.java b/src/test/java/com/mindee/v1/product/generated/GeneratedV1Test.java similarity index 95% rename from src/test/java/com/mindee/product/generated/GeneratedV1Test.java rename to src/test/java/com/mindee/v1/product/generated/GeneratedV1Test.java index 13683ecf8..7901d0f6a 100644 --- a/src/test/java/com/mindee/product/generated/GeneratedV1Test.java +++ b/src/test/java/com/mindee/v1/product/generated/GeneratedV1Test.java @@ -1,18 +1,18 @@ -package com.mindee.product.generated; +package com.mindee.v1.product.generated; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.generated.GeneratedFeature; -import com.mindee.parsing.generated.GeneratedObject; -import com.mindee.parsing.standard.AmountField; -import com.mindee.parsing.standard.BooleanField; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.generated.GeneratedFeature; +import com.mindee.v1.parsing.generated.GeneratedObject; +import com.mindee.v1.parsing.standard.AmountField; +import com.mindee.v1.parsing.standard.BooleanField; +import com.mindee.v1.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.standard.DateField; +import com.mindee.v1.parsing.standard.StringField; import java.io.File; import java.io.IOException; import java.time.LocalDate; diff --git a/src/test/java/com/mindee/product/ind/indianpassport/IndianPassportV1Test.java b/src/test/java/com/mindee/v1/product/ind/indianpassport/IndianPassportV1Test.java similarity index 93% rename from src/test/java/com/mindee/product/ind/indianpassport/IndianPassportV1Test.java rename to src/test/java/com/mindee/v1/product/ind/indianpassport/IndianPassportV1Test.java index 02c3b68d5..c702be1a0 100644 --- a/src/test/java/com/mindee/product/ind/indianpassport/IndianPassportV1Test.java +++ b/src/test/java/com/mindee/v1/product/ind/indianpassport/IndianPassportV1Test.java @@ -1,13 +1,13 @@ -package com.mindee.product.ind.indianpassport; +package com.mindee.v1.product.ind.indianpassport; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.standard.ClassificationField; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/internationalid/InternationalIdV2Test.java b/src/test/java/com/mindee/v1/product/internationalid/InternationalIdV2Test.java similarity index 93% rename from src/test/java/com/mindee/product/internationalid/InternationalIdV2Test.java rename to src/test/java/com/mindee/v1/product/internationalid/InternationalIdV2Test.java index 5833c8d67..5a2ba4966 100644 --- a/src/test/java/com/mindee/product/internationalid/InternationalIdV2Test.java +++ b/src/test/java/com/mindee/v1/product/internationalid/InternationalIdV2Test.java @@ -1,13 +1,13 @@ -package com.mindee.product.internationalid; +package com.mindee.v1.product.internationalid; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.standard.ClassificationField; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/invoice/InvoiceV4Test.java b/src/test/java/com/mindee/v1/product/invoice/InvoiceV4Test.java similarity index 94% rename from src/test/java/com/mindee/product/invoice/InvoiceV4Test.java rename to src/test/java/com/mindee/v1/product/invoice/InvoiceV4Test.java index 9e4027f75..e1c00fd62 100644 --- a/src/test/java/com/mindee/product/invoice/InvoiceV4Test.java +++ b/src/test/java/com/mindee/v1/product/invoice/InvoiceV4Test.java @@ -1,13 +1,13 @@ -package com.mindee.product.invoice; +package com.mindee.v1.product.invoice; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.standard.ClassificationField; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1Test.java b/src/test/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1Test.java similarity index 92% rename from src/test/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1Test.java rename to src/test/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1Test.java index 863f58dd8..baedb539d 100644 --- a/src/test/java/com/mindee/product/invoicesplitter/InvoiceSplitterV1Test.java +++ b/src/test/java/com/mindee/v1/product/invoicesplitter/InvoiceSplitterV1Test.java @@ -1,12 +1,12 @@ -package com.mindee.product.invoicesplitter; +package com.mindee.v1.product.invoicesplitter; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/multireceiptsdetector/MultiReceiptsDetectorV1Test.java b/src/test/java/com/mindee/v1/product/multireceiptsdetector/MultiReceiptsDetectorV1Test.java similarity index 92% rename from src/test/java/com/mindee/product/multireceiptsdetector/MultiReceiptsDetectorV1Test.java rename to src/test/java/com/mindee/v1/product/multireceiptsdetector/MultiReceiptsDetectorV1Test.java index d0aae9d78..317791e12 100644 --- a/src/test/java/com/mindee/product/multireceiptsdetector/MultiReceiptsDetectorV1Test.java +++ b/src/test/java/com/mindee/v1/product/multireceiptsdetector/MultiReceiptsDetectorV1Test.java @@ -1,12 +1,12 @@ -package com.mindee.product.multireceiptsdetector; +package com.mindee.v1.product.multireceiptsdetector; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/passport/PassportV1Test.java b/src/test/java/com/mindee/v1/product/passport/PassportV1Test.java similarity index 94% rename from src/test/java/com/mindee/product/passport/PassportV1Test.java rename to src/test/java/com/mindee/v1/product/passport/PassportV1Test.java index 9ba9121fc..d671d1211 100644 --- a/src/test/java/com/mindee/product/passport/PassportV1Test.java +++ b/src/test/java/com/mindee/v1/product/passport/PassportV1Test.java @@ -1,12 +1,12 @@ -package com.mindee.product.passport; +package com.mindee.v1.product.passport; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/product/receipt/ReceiptV5Test.java b/src/test/java/com/mindee/v1/product/receipt/ReceiptV5Test.java similarity index 93% rename from src/test/java/com/mindee/product/receipt/ReceiptV5Test.java rename to src/test/java/com/mindee/v1/product/receipt/ReceiptV5Test.java index fd1466201..ef78a50c0 100644 --- a/src/test/java/com/mindee/product/receipt/ReceiptV5Test.java +++ b/src/test/java/com/mindee/v1/product/receipt/ReceiptV5Test.java @@ -1,13 +1,13 @@ -package com.mindee.product.receipt; +package com.mindee.v1.product.receipt; import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; +import com.mindee.v1.parsing.common.Document; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.standard.ClassificationField; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/mindee/workflow/WorkflowIT.java b/src/test/java/com/mindee/v1/workflow/WorkflowIT.java similarity index 85% rename from src/test/java/com/mindee/workflow/WorkflowIT.java rename to src/test/java/com/mindee/v1/workflow/WorkflowIT.java index 323dde272..1f848415f 100644 --- a/src/test/java/com/mindee/workflow/WorkflowIT.java +++ b/src/test/java/com/mindee/v1/workflow/WorkflowIT.java @@ -1,17 +1,17 @@ -package com.mindee.workflow; +package com.mindee.v1.workflow; import static com.mindee.TestingUtilities.getV1ResourcePath; -import com.mindee.MindeeClient; -import com.mindee.PredictOptions; -import com.mindee.WorkflowOptions; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.parsing.common.Execution; -import com.mindee.parsing.common.ExecutionPriority; -import com.mindee.parsing.common.WorkflowResponse; -import com.mindee.product.financialdocument.FinancialDocumentV1; -import com.mindee.product.generated.GeneratedV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.clientOptions.PredictOptions; +import com.mindee.v1.clientOptions.WorkflowOptions; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.Execution; +import com.mindee.v1.parsing.common.ExecutionPriority; +import com.mindee.v1.parsing.common.WorkflowResponse; +import com.mindee.v1.product.financialdocument.FinancialDocumentV1; +import com.mindee.v1.product.generated.GeneratedV1; import java.io.IOException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; diff --git a/src/test/java/com/mindee/workflow/WorkflowTest.java b/src/test/java/com/mindee/v1/workflow/WorkflowTest.java similarity index 94% rename from src/test/java/com/mindee/workflow/WorkflowTest.java rename to src/test/java/com/mindee/v1/workflow/WorkflowTest.java index cba596487..53110badd 100644 --- a/src/test/java/com/mindee/workflow/WorkflowTest.java +++ b/src/test/java/com/mindee/v1/workflow/WorkflowTest.java @@ -1,17 +1,17 @@ -package com.mindee.workflow; +package com.mindee.v1.workflow; import static com.mindee.TestingUtilities.getResourcePath; import static com.mindee.TestingUtilities.getV1ResourcePath; import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.MindeeClient; -import com.mindee.http.MindeeApi; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.Execution; -import com.mindee.parsing.common.WorkflowResponse; import com.mindee.pdf.PdfOperation; -import com.mindee.product.generated.GeneratedV1; +import com.mindee.v1.MindeeClient; +import com.mindee.v1.http.MindeeApiV1; +import com.mindee.v1.parsing.common.Execution; +import com.mindee.v1.parsing.common.WorkflowResponse; +import com.mindee.v1.product.generated.GeneratedV1; import java.io.IOException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -27,14 +27,14 @@ public class WorkflowTest { MindeeClient client; @Mock MindeeClient mockedClient; - MindeeApi mindeeApi; + MindeeApiV1 mindeeApi; PdfOperation pdfOperation; private ObjectMapper objectMapper; @BeforeEach public void setUp() { - mindeeApi = Mockito.mock(MindeeApi.class); + mindeeApi = Mockito.mock(MindeeApiV1.class); pdfOperation = Mockito.mock(PdfOperation.class); client = new MindeeClient(pdfOperation, mindeeApi); diff --git a/src/test/java/com/mindee/MindeeClientV2IT.java b/src/test/java/com/mindee/v2/MindeeClientIT.java similarity index 77% rename from src/test/java/com/mindee/MindeeClientV2IT.java rename to src/test/java/com/mindee/v2/MindeeClientIT.java index c96225be5..e82f3c5fa 100644 --- a/src/test/java/com/mindee/MindeeClientV2IT.java +++ b/src/test/java/com/mindee/v2/MindeeClientIT.java @@ -1,37 +1,39 @@ -package com.mindee; +package com.mindee.v2; import static com.mindee.TestingUtilities.getResourcePath; import static com.mindee.TestingUtilities.getV2ResourcePath; import static com.mindee.TestingUtilities.readFileAsString; import static org.junit.jupiter.api.Assertions.*; -import com.mindee.http.MindeeHttpExceptionV2; +import com.mindee.AsyncPollingOptions; import com.mindee.input.LocalInputSource; import com.mindee.input.URLInputSource; -import com.mindee.parsing.v2.Inference; -import com.mindee.parsing.v2.InferenceActiveOptions; -import com.mindee.parsing.v2.InferenceFile; -import com.mindee.parsing.v2.InferenceResponse; -import com.mindee.parsing.v2.InferenceResult; -import com.mindee.parsing.v2.RawText; -import com.mindee.parsing.v2.field.InferenceFields; -import com.mindee.parsing.v2.field.SimpleField; +import com.mindee.v2.http.MindeeHttpExceptionV2; +import com.mindee.v2.parsing.inference.InferenceActiveOptions; +import com.mindee.v2.parsing.inference.InferenceFile; +import com.mindee.v2.parsing.inference.RawText; +import com.mindee.v2.parsing.inference.field.InferenceFields; +import com.mindee.v2.parsing.inference.field.SimpleField; +import com.mindee.v2.product.extraction.ExtractionInference; +import com.mindee.v2.product.extraction.ExtractionResponse; +import com.mindee.v2.product.extraction.ExtractionResult; +import com.mindee.v2.product.extraction.params.ExtractionParameters; import java.io.IOException; import org.junit.jupiter.api.*; @TestInstance(TestInstance.Lifecycle.PER_CLASS) @Tag("integration") @DisplayName("MindeeV2 – Integration Tests") -class MindeeClientV2IT { +class MindeeClientIT { - private MindeeClientV2 mindeeClient; + private MindeeClient mindeeClient; private String modelId; @BeforeAll void setUp() { String apiKey = System.getenv("MINDEE_V2_API_KEY"); modelId = System.getenv("MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID"); - mindeeClient = new MindeeClientV2(apiKey); + mindeeClient = new MindeeClient(apiKey); } @Test @@ -40,7 +42,7 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep LocalInputSource source = new LocalInputSource( getResourcePath("file_types/pdf/multipage_cut-2.pdf") ); - InferenceParameters params = InferenceParameters + ExtractionParameters params = ExtractionParameters .builder(modelId) .rag(false) .rawText(true) @@ -53,10 +55,10 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep ) .build(); - InferenceResponse response = mindeeClient - .enqueueAndGetResult(InferenceResponse.class, source, params); + ExtractionResponse response = mindeeClient + .enqueueAndGetResult(ExtractionResponse.class, source, params); assertNotNull(response); - Inference inference = response.getInference(); + ExtractionInference inference = response.getInference(); assertNotNull(inference); InferenceFile file = inference.getFile(); @@ -74,7 +76,7 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep assertFalse(activeOptions.getPolygon()); assertFalse(activeOptions.getConfidence()); - InferenceResult result = inference.getResult(); + ExtractionResult result = inference.getResult(); assertNotNull(result); RawText rawText = result.getRawText(); @@ -91,16 +93,16 @@ void parseFile_filledSinglePage_mustSucceed() throws IOException, InterruptedExc getV2ResourcePath("products/extraction/financial_document/default_sample.jpg") ); - InferenceParameters params = InferenceParameters + ExtractionParameters params = ExtractionParameters .builder(modelId) .rag(false) .alias("java-integration-test_single-page") .textContext("this is an invoice") .build(); - InferenceResponse response = mindeeClient.enqueueAndGetInference(source, params); + ExtractionResponse response = mindeeClient.enqueueAndGetInference(source, params); assertNotNull(response); - Inference inference = response.getInference(); + ExtractionInference inference = response.getInference(); assertNotNull(inference); InferenceFile file = inference.getFile(); @@ -118,7 +120,7 @@ void parseFile_filledSinglePage_mustSucceed() throws IOException, InterruptedExc assertFalse(activeOptions.getPolygon()); assertFalse(activeOptions.getConfidence()); - InferenceResult result = inference.getResult(); + ExtractionResult result = inference.getResult(); assertNotNull(result); RawText rawText = result.getRawText(); @@ -139,7 +141,7 @@ void parseFile_dataSchemaReplace_mustSucceed() throws IOException, InterruptedEx getV2ResourcePath("products/extraction/financial_document/default_sample.jpg") ); - InferenceParameters params = InferenceParameters + ExtractionParameters params = ExtractionParameters .builder(modelId) .rag(false) .alias("java-integration-test_data-schema-replace") @@ -148,13 +150,13 @@ void parseFile_dataSchemaReplace_mustSucceed() throws IOException, InterruptedEx ) .build(); - InferenceResponse response = mindeeClient - .enqueueAndGetResult(InferenceResponse.class, source, params); + ExtractionResponse response = mindeeClient + .enqueueAndGetResult(ExtractionResponse.class, source, params); assertNotNull(response); - Inference inference = response.getInference(); + ExtractionInference inference = response.getInference(); assertNotNull(inference); - InferenceResult result = inference.getResult(); + ExtractionResult result = inference.getResult(); assertNotNull(result); RawText rawText = result.getRawText(); @@ -172,7 +174,7 @@ void parseFile_dataSchemaReplace_mustSucceed() throws IOException, InterruptedEx @DisplayName("Invalid model ID – enqueue must raise 422") void invalidModel_mustThrowError() throws IOException { LocalInputSource source = new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf")); - InferenceParameters params = InferenceParameters + ExtractionParameters params = ExtractionParameters .builder("INVALID_MODEL_ID") .textContext("this is invalid") .build(); @@ -188,7 +190,7 @@ void invalidModel_mustThrowError() throws IOException { @DisplayName("Invalid webhook ID – enqueue must raise 422") void invalidWebhook_mustThrowError() throws IOException { LocalInputSource source = new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf")); - InferenceParameters params = InferenceParameters + ExtractionParameters params = ExtractionParameters .builder(modelId) .webhookIds(new String[] { "INVALID_WEBHOOK_ID" }) .build(); @@ -218,9 +220,9 @@ void urlInputSource_mustNotRaiseErrors() throws IOException, InterruptedExceptio .builder(System.getenv("MINDEE_V2_SE_TESTS_BLANK_PDF_URL")) .build(); - InferenceParameters options = InferenceParameters.builder(modelId).build(); + ExtractionParameters options = ExtractionParameters.builder(modelId).build(); - InferenceResponse response = mindeeClient.enqueueAndGetInference(urlSource, options); + ExtractionResponse response = mindeeClient.enqueueAndGetInference(urlSource, options); assertNotNull(response); assertNotNull(response.getInference()); diff --git a/src/test/java/com/mindee/MindeeClientV2Test.java b/src/test/java/com/mindee/v2/MindeeClientTest.java similarity index 77% rename from src/test/java/com/mindee/MindeeClientV2Test.java rename to src/test/java/com/mindee/v2/MindeeClientTest.java index 90ddb2b4a..5cf1d2a27 100644 --- a/src/test/java/com/mindee/MindeeClientV2Test.java +++ b/src/test/java/com/mindee/v2/MindeeClientTest.java @@ -1,4 +1,4 @@ -package com.mindee; +package com.mindee.v2; import static com.mindee.TestingUtilities.getResourcePath; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -10,11 +10,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.http.MindeeApiV2; import com.mindee.input.LocalInputSource; import com.mindee.input.LocalResponse; -import com.mindee.parsing.v2.InferenceResponse; -import com.mindee.parsing.v2.JobResponse; +import com.mindee.v2.http.MindeeApiV2; +import com.mindee.v2.parsing.JobResponse; +import com.mindee.v2.product.extraction.ExtractionResponse; +import com.mindee.v2.product.extraction.params.ExtractionParameters; import java.io.IOException; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.DisplayName; @@ -23,12 +24,12 @@ import org.mockito.Mockito; @DisplayName("MindeeV2 – Client and API Tests") -class MindeeClientV2Test { +class MindeeClientTest { /** * Creates a fully mocked MindeeClientV2. */ - private static MindeeClientV2 makeClientWithMockedApi(MindeeApiV2 mockedApi) { - return new MindeeClientV2(mockedApi); + private static MindeeClient makeClientWithMockedApi(MindeeApiV2 mockedApi) { + return new MindeeClient(mockedApi); } @Nested @@ -38,21 +39,21 @@ class Enqueue { @DisplayName("sends exactly one HTTP call and yields a non-null response") void enqueue_post_async() throws IOException { MindeeApiV2 predictable = Mockito.mock(MindeeApiV2.class); - when(predictable.reqPostEnqueue(any(LocalInputSource.class), any(InferenceParameters.class))) + when(predictable.reqPostEnqueue(any(LocalInputSource.class), any(ExtractionParameters.class))) .thenReturn(new JobResponse()); - MindeeClientV2 mindeeClient = makeClientWithMockedApi(predictable); + MindeeClient mindeeClient = makeClientWithMockedApi(predictable); LocalInputSource input = new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf")); JobResponse response = mindeeClient .enqueueInference( input, - InferenceParameters.builder("dummy-model-id").textContext("test text context").build() + ExtractionParameters.builder("dummy-model-id").textContext("test text context").build() ); assertNotNull(response, "enqueue() must return a response"); verify(predictable, atMostOnce()) - .reqPostEnqueue(any(LocalInputSource.class), any(InferenceParameters.class)); + .reqPostEnqueue(any(LocalInputSource.class), any(ExtractionParameters.class)); } } @@ -71,7 +72,7 @@ void document_getJob_async() throws JsonProcessingException { when(predictable.reqGetJob(anyString())).thenReturn(processing); - MindeeClientV2 mindeeClient = makeClientWithMockedApi(predictable); + MindeeClient mindeeClient = makeClientWithMockedApi(predictable); JobResponse response = mindeeClient.getJob("dummy-id"); assertNotNull(response, "getJob() must return a response"); @@ -81,7 +82,7 @@ void document_getJob_async() throws JsonProcessingException { @Nested @DisplayName("getInference()") - class GetInference { + class GetExtractionInference { @Test @DisplayName("hits the HTTP endpoint once and returns a non-null response") void document_getInference_async() throws IOException { @@ -95,14 +96,14 @@ void document_getInference_async() throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.findAndRegisterModules(); - InferenceResponse processing = mapper.readValue(json, InferenceResponse.class); + ExtractionResponse processing = mapper.readValue(json, ExtractionResponse.class); - when(predictable.reqGetResult(eq(InferenceResponse.class), anyString())) + when(predictable.reqGetResult(eq(ExtractionResponse.class), anyString())) .thenReturn(processing); - MindeeClientV2 mindeeClient = makeClientWithMockedApi(predictable); + MindeeClient mindeeClient = makeClientWithMockedApi(predictable); - InferenceResponse response = mindeeClient + ExtractionResponse response = mindeeClient .getInference("12345678-1234-1234-1234-123456789abc"); assertNotNull(response, "getInference() must return a response"); assertEquals( @@ -121,7 +122,7 @@ void document_getInference_async() throws IOException { .getValue(), "Result must deserialize fields properly." ); - verify(predictable, atMostOnce()).reqGetResult(eq(InferenceResponse.class), anyString()); + verify(predictable, atMostOnce()).reqGetResult(eq(ExtractionResponse.class), anyString()); } } @@ -135,7 +136,7 @@ void inference_loadsLocally() throws IOException { LocalResponse localResponse = new LocalResponse( getResourcePath("v2/products/extraction/financial_document/complete.json") ); - InferenceResponse loaded = localResponse.deserializeResponse(InferenceResponse.class); + ExtractionResponse loaded = localResponse.deserializeResponse(ExtractionResponse.class); assertNotNull(loaded, "Loaded InferenceResponse must not be null"); assertEquals( diff --git a/src/test/java/com/mindee/v2/MindeeSettingsTest.java b/src/test/java/com/mindee/v2/MindeeSettingsTest.java new file mode 100644 index 000000000..797c5692e --- /dev/null +++ b/src/test/java/com/mindee/v2/MindeeSettingsTest.java @@ -0,0 +1,17 @@ +package com.mindee.v2; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.SetEnvironmentVariable; + +public class MindeeSettingsTest { + + @Test + @SetEnvironmentVariable(key = "MINDEE_V2_API_KEY", value = "abcd") + @SetEnvironmentVariable(key = "MINDEE_V2_API_URL", value = "https://example.com") + void setEnvironmentVariablesAndEmptyParams() { + MindeeSettings settings = new MindeeSettings("", ""); + Assertions.assertEquals("abcd", settings.getApiKey().orElse("")); + Assertions.assertEquals("https://example.com", settings.getBaseUrl()); + } +} diff --git a/src/test/java/com/mindee/parsing/v2/ExtractionTest.java b/src/test/java/com/mindee/v2/parsing/ExtractionTest.java similarity index 87% rename from src/test/java/com/mindee/parsing/v2/ExtractionTest.java rename to src/test/java/com/mindee/v2/parsing/ExtractionTest.java index 25700634e..1fabb85d2 100644 --- a/src/test/java/com/mindee/parsing/v2/ExtractionTest.java +++ b/src/test/java/com/mindee/v2/parsing/ExtractionTest.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing; import static com.mindee.TestingUtilities.getV2ResourcePath; import static com.mindee.TestingUtilities.readFileAsString; @@ -13,14 +13,23 @@ import com.mindee.geometry.Point; import com.mindee.geometry.Polygon; import com.mindee.input.LocalResponse; -import com.mindee.parsing.v2.field.DynamicField; -import com.mindee.parsing.v2.field.DynamicField.FieldType; -import com.mindee.parsing.v2.field.FieldConfidence; -import com.mindee.parsing.v2.field.FieldLocation; -import com.mindee.parsing.v2.field.InferenceFields; -import com.mindee.parsing.v2.field.ListField; -import com.mindee.parsing.v2.field.ObjectField; -import com.mindee.parsing.v2.field.SimpleField; +import com.mindee.v2.parsing.inference.InferenceActiveOptions; +import com.mindee.v2.parsing.inference.InferenceFile; +import com.mindee.v2.parsing.inference.InferenceJob; +import com.mindee.v2.parsing.inference.InferenceModel; +import com.mindee.v2.parsing.inference.RagMetadata; +import com.mindee.v2.parsing.inference.RawText; +import com.mindee.v2.parsing.inference.RawTextPage; +import com.mindee.v2.parsing.inference.field.DynamicField; +import com.mindee.v2.parsing.inference.field.DynamicField.FieldType; +import com.mindee.v2.parsing.inference.field.FieldConfidence; +import com.mindee.v2.parsing.inference.field.FieldLocation; +import com.mindee.v2.parsing.inference.field.InferenceFields; +import com.mindee.v2.parsing.inference.field.ListField; +import com.mindee.v2.parsing.inference.field.ObjectField; +import com.mindee.v2.parsing.inference.field.SimpleField; +import com.mindee.v2.product.extraction.ExtractionInference; +import com.mindee.v2.product.extraction.ExtractionResponse; import java.io.IOException; import java.math.BigDecimal; import java.util.HashMap; @@ -34,9 +43,9 @@ @DisplayName("MindeeV2 - Extraction Model Tests") class ExtractionTest { - private InferenceResponse loadResponse(String filePath) throws IOException { + private ExtractionResponse loadResponse(String filePath) throws IOException { LocalResponse localResponse = new LocalResponse(getV2ResourcePath(filePath)); - return localResponse.deserializeResponse(InferenceResponse.class); + return localResponse.deserializeResponse(ExtractionResponse.class); } @Nested @@ -46,7 +55,7 @@ class BlankPredictionTest { @Test @DisplayName("all properties must be valid") void asyncPredict_whenEmpty_mustHaveValidProperties() throws IOException { - InferenceResponse response = loadResponse( + ExtractionResponse response = loadResponse( "products/extraction/financial_document/blank.json" ); InferenceFields fields = response.getInference().getResult().getFields(); @@ -100,10 +109,10 @@ class CompletePredictionTest { @Test @DisplayName("every exposed property must be valid and consistent") void asyncPredict_whenComplete_mustExposeAllProperties() throws IOException { - InferenceResponse response = loadResponse( + ExtractionResponse response = loadResponse( "products/extraction/financial_document/complete.json" ); - Inference inference = response.getInference(); + ExtractionInference inference = response.getInference(); assertNotNull(inference); assertEquals("12345678-1234-1234-1234-123456789abc", inference.getId()); @@ -175,8 +184,8 @@ class DeepNestedFieldsTest { @Test @DisplayName("all nested structures must be typed correctly") void deepNestedFields_mustExposeCorrectTypes() throws IOException { - InferenceResponse resp = loadResponse("products/extraction/deep_nested_fields.json"); - Inference inf = resp.getInference(); + ExtractionResponse resp = loadResponse("products/extraction/deep_nested_fields.json"); + ExtractionInference inf = resp.getInference(); assertNotNull(inf); InferenceFields root = inf.getResult().getFields(); @@ -241,8 +250,8 @@ private void testSimpleFieldString(SimpleField field) { @Test @DisplayName("simple fields must be recognised") void standardFieldTypes_mustExposeSimpleFieldValues() throws IOException { - InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); - Inference inference = response.getInference(); + ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); + ExtractionInference inference = response.getInference(); assertNotNull(inference); InferenceFields fields = inference.getResult().getFields(); @@ -298,8 +307,8 @@ void standardFieldTypes_mustExposeSimpleFieldValues() throws IOException { @Test @DisplayName("simple list fields must be recognised") void standardFieldTypes_mustExposeSimpleListFieldValues() throws IOException { - InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); - Inference inference = response.getInference(); + ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); + ExtractionInference inference = response.getInference(); assertNotNull(inference); InferenceFields fields = inference.getResult().getFields(); @@ -341,8 +350,8 @@ private void testObjectSubFieldSimpleString(String fieldName, SimpleField subFie @Test @DisplayName("object list fields must be recognised") void standardFieldTypes_mustExposeObjectListFieldValues() throws IOException { - InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); - Inference inference = response.getInference(); + ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); + ExtractionInference inference = response.getInference(); assertNotNull(inference); InferenceFields fields = inference.getResult().getFields(); @@ -391,8 +400,8 @@ void standardFieldTypes_mustExposeObjectListFieldValues() throws IOException { @Test @DisplayName("simple / object / list variants must be recognised") void standardFieldTypes_mustExposeObjectFieldValues() throws IOException { - InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); - Inference inference = response.getInference(); + ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); + ExtractionInference inference = response.getInference(); assertNotNull(inference); InferenceFields fields = inference.getResult().getFields(); @@ -426,8 +435,8 @@ void standardFieldTypes_mustExposeObjectFieldValues() throws IOException { @Test @DisplayName("allow getting fields using generics") void standardFieldTypes_getWithGenerics() throws IOException { - InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); - Inference inference = response.getInference(); + ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); + ExtractionInference inference = response.getInference(); assertNotNull(inference); InferenceFields fields = inference.getResult().getFields(); @@ -462,8 +471,8 @@ void standardFieldTypes_getWithGenerics() throws IOException { @Test @DisplayName("confidence and locations must be usable") void standardFieldTypes_confidenceAndLocations() throws IOException { - InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); - Inference inference = response.getInference(); + ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); + ExtractionInference inference = response.getInference(); assertNotNull(inference); InferenceFields fields = inference.getResult().getFields(); @@ -502,8 +511,8 @@ class RawTextTest { @Test @DisplayName("raw texts option must be parsed and exposed") void rawTexts_mustBeAccessible() throws IOException { - InferenceResponse response = loadResponse("products/extraction/raw_texts.json"); - Inference inference = response.getInference(); + ExtractionResponse response = loadResponse("products/extraction/raw_texts.json"); + ExtractionInference inference = response.getInference(); assertNotNull(inference); InferenceActiveOptions activeOptions = inference.getActiveOptions(); @@ -537,8 +546,8 @@ class RagMetadataTest { @Test @DisplayName("RAG metadata when matched") void rag_mustBeFilled_whenMatched() throws IOException { - InferenceResponse response = loadResponse("products/extraction/rag_matched.json"); - Inference inference = response.getInference(); + ExtractionResponse response = loadResponse("products/extraction/rag_matched.json"); + ExtractionInference inference = response.getInference(); assertNotNull(inference); RagMetadata rag = inference.getResult().getRag(); @@ -549,8 +558,8 @@ void rag_mustBeFilled_whenMatched() throws IOException { @Test @DisplayName("RAG metadata when not matched") void rag_mustBeNull_whenNotMatched() throws IOException { - InferenceResponse response = loadResponse("products/extraction/rag_not_matched.json"); - Inference inference = response.getInference(); + ExtractionResponse response = loadResponse("products/extraction/rag_not_matched.json"); + ExtractionInference inference = response.getInference(); assertNotNull(inference); RagMetadata rag = inference.getResult().getRag(); @@ -565,11 +574,11 @@ class RstDisplay { @Test @DisplayName("rst display must be parsed and exposed") void rstDisplay_mustBeAccessible() throws IOException { - InferenceResponse resp = loadResponse("products/extraction/standard_field_types.json"); + ExtractionResponse resp = loadResponse("products/extraction/standard_field_types.json"); String rstRef = readFileAsString( getV2ResourcePath("products/extraction/standard_field_types.rst") ); - Inference inference = resp.getInference(); + ExtractionInference inference = resp.getInference(); assertNotNull(inference); assertEquals(rstRef, resp.getInference().toString()); } @@ -581,8 +590,8 @@ class TextContextTest { @Test @DisplayName("should be present and true when enabled") void textContext_mustBePresentAndTrue() throws IOException { - InferenceResponse resp = loadResponse("products/extraction/text_context_enabled.json"); - Inference inference = resp.getInference(); + ExtractionResponse resp = loadResponse("products/extraction/text_context_enabled.json"); + ExtractionInference inference = resp.getInference(); assertNotNull(inference); assertTrue(inference.getActiveOptions().getTextContext()); } @@ -594,8 +603,8 @@ class DataSchemaTest { @Test @DisplayName("should be present and true when enabled") void textContext_mustBePresentAndTrue() throws IOException { - InferenceResponse resp = loadResponse("products/extraction/data_schema_replace.json"); - Inference inference = resp.getInference(); + ExtractionResponse resp = loadResponse("products/extraction/data_schema_replace.json"); + ExtractionInference inference = resp.getInference(); assertNotNull(inference); InferenceFields fields = inference.getResult().getFields(); assertEquals("a test value", fields.get("test_replace").getSimpleField().getStringValue()); diff --git a/src/test/java/com/mindee/parsing/v2/JobTest.java b/src/test/java/com/mindee/v2/parsing/JobTest.java similarity index 98% rename from src/test/java/com/mindee/parsing/v2/JobTest.java rename to src/test/java/com/mindee/v2/parsing/JobTest.java index 7d905a752..e4d2f3c8b 100644 --- a/src/test/java/com/mindee/parsing/v2/JobTest.java +++ b/src/test/java/com/mindee/v2/parsing/JobTest.java @@ -1,4 +1,4 @@ -package com.mindee.parsing.v2; +package com.mindee.v2.parsing; import static com.mindee.TestingUtilities.getV2ResourcePath; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/com/mindee/v2/product/CropIT.java b/src/test/java/com/mindee/v2/product/CropIT.java index f4d445967..9aa3abff3 100644 --- a/src/test/java/com/mindee/v2/product/CropIT.java +++ b/src/test/java/com/mindee/v2/product/CropIT.java @@ -4,9 +4,9 @@ import static org.junit.jupiter.api.Assertions.*; import com.mindee.AsyncPollingOptions; -import com.mindee.MindeeClientV2; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.v2.InferenceFile; +import com.mindee.v2.MindeeClient; +import com.mindee.v2.parsing.inference.InferenceFile; import com.mindee.v2.product.crop.CropInference; import com.mindee.v2.product.crop.CropResponse; import com.mindee.v2.product.crop.CropResult; @@ -23,14 +23,14 @@ @DisplayName("MindeeV2 –Integration Tests - Crop") class CropIT { - private MindeeClientV2 mindeeClient; + private MindeeClient mindeeClient; private String modelId; @BeforeAll void setUp() { String apiKey = System.getenv("MINDEE_V2_API_KEY"); modelId = System.getenv("MINDEE_V2_SE_TESTS_CROP_MODEL_ID"); - mindeeClient = new MindeeClientV2(apiKey); + mindeeClient = new MindeeClient(apiKey); } @Test diff --git a/src/test/java/com/mindee/v2/product/SplitIT.java b/src/test/java/com/mindee/v2/product/SplitIT.java index ce897416a..8c536b528 100644 --- a/src/test/java/com/mindee/v2/product/SplitIT.java +++ b/src/test/java/com/mindee/v2/product/SplitIT.java @@ -6,9 +6,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import com.mindee.AsyncPollingOptions; -import com.mindee.MindeeClientV2; import com.mindee.input.LocalInputSource; -import com.mindee.parsing.v2.InferenceFile; +import com.mindee.v2.MindeeClient; +import com.mindee.v2.parsing.inference.InferenceFile; import com.mindee.v2.product.split.SplitInference; import com.mindee.v2.product.split.SplitResponse; import com.mindee.v2.product.split.SplitResult; @@ -25,14 +25,14 @@ @DisplayName("MindeeV2 –Integration Tests - Split") class SplitIT { - private MindeeClientV2 mindeeClient; + private MindeeClient mindeeClient; private String modelId; @BeforeAll void setUp() { String apiKey = System.getenv("MINDEE_V2_API_KEY"); modelId = System.getenv("MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID"); - mindeeClient = new MindeeClientV2(apiKey); + mindeeClient = new MindeeClient(apiKey); } @Test From 3691852891fdec4572d04fc999038e58141fcfe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Fri, 3 Apr 2026 11:42:33 +0200 Subject: [PATCH 3/9] bump version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 23a33a0a1..54327a6ee 100644 --- a/pom.xml +++ b/pom.xml @@ -416,7 +416,7 @@ - 4.43.1 + 5.0.0-alpha1 2.15.4 2.15.4 From 6c06a731589acd08712c6184ff1e59a6d7fcc09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Tue, 7 Apr 2026 10:52:01 +0200 Subject: [PATCH 4/9] :boom: drop support for Java 1.8 (#310) --- .github/workflows/_build.yml | 2 +- .github/workflows/_publish-code.yml | 2 +- .github/workflows/_test-code-samples.yml | 1 - .github/workflows/_test-integrations.yml | 3 +- pom.xml | 48 ++-- .../java/com/mindee/v1/http/MindeeApiV1.java | 3 + src/main/java/com/mindee/v2/MindeeClient.java | 48 ---- .../java/com/mindee/TestingUtilities.java | 5 - .../com/mindee/input/URLInputSourceTest.java | 62 +++-- .../java/com/mindee/v1/FakeMindeeApiV1.java | 71 +++++ .../java/com/mindee/v1/MindeeClientTest.java | 242 +++--------------- .../com/mindee/v1/workflow/WorkflowTest.java | 54 +--- .../java/com/mindee/v2/MindeeClientIT.java | 102 ++++---- .../java/com/mindee/v2/MindeeClientTest.java | 97 +++---- .../com/mindee/v2/MindeeSettingsTest.java | 2 +- .../com/mindee/v2/parsing/ExtractionTest.java | 91 ++++--- .../java/com/mindee/v2/parsing/JobTest.java | 14 +- .../mindee/v2/product/ClassificationTest.java | 2 +- .../java/com/mindee/v2/product/CropIT.java | 16 +- .../java/com/mindee/v2/product/CropTest.java | 22 +- .../java/com/mindee/v2/product/OcrTest.java | 16 +- .../java/com/mindee/v2/product/SplitIT.java | 20 +- .../java/com/mindee/v2/product/SplitTest.java | 18 +- 23 files changed, 383 insertions(+), 558 deletions(-) create mode 100644 src/test/java/com/mindee/v1/FakeMindeeApiV1.java diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index 4189be39d..ab99c49d1 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -11,10 +11,10 @@ jobs: strategy: matrix: java-version: + - "25" - "21" - "17" - "11" - - "8" distribution: - "temurin" diff --git a/.github/workflows/_publish-code.yml b/.github/workflows/_publish-code.yml index 757cfc03f..bd481ce15 100644 --- a/.github/workflows/_publish-code.yml +++ b/.github/workflows/_publish-code.yml @@ -22,7 +22,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v5 with: - java-version: "8" + java-version: "11" distribution: "adopt" server-id: central server-username: MAVEN_USERNAME diff --git a/.github/workflows/_test-code-samples.yml b/.github/workflows/_test-code-samples.yml index 1d58d737e..924f479d0 100644 --- a/.github/workflows/_test-code-samples.yml +++ b/.github/workflows/_test-code-samples.yml @@ -23,7 +23,6 @@ jobs: java-version: - "25" - "11" - - "8" distribution: - "temurin" diff --git a/.github/workflows/_test-integrations.yml b/.github/workflows/_test-integrations.yml index d06e361aa..6e5474996 100644 --- a/.github/workflows/_test-integrations.yml +++ b/.github/workflows/_test-integrations.yml @@ -23,9 +23,8 @@ jobs: strategy: matrix: java-version: - - "21" + - "25" - "11" - - "8" distribution: - "temurin" diff --git a/pom.xml b/pom.xml index 54327a6ee..ceb1a2d9e 100644 --- a/pom.xml +++ b/pom.xml @@ -90,8 +90,8 @@ ${org.projectlombok.lombok-mapstruct-binding.version} - 1.8 - 1.8 + 11 + 11 @@ -102,7 +102,7 @@ false true 3 - 1.8 + 11 @@ -129,8 +129,8 @@ org.apache.maven.plugins maven-compiler-plugin - 8 - 8 + 11 + 11 @@ -290,8 +290,8 @@ jackson-databind - com.fasterxml.jackson.core - ${com.fasterxml.jackson.version} + tools.jackson.core + ${tools.jackson.core.databind.version} jackson-datatype-jsr310 @@ -366,21 +366,8 @@ junit-pioneer org.junit-pioneer test - ${org.junit.pioneer.version} - - mockito-junit-jupiter - org.mockito - test - ${org.mockito.junit.jupiter.version} - - - mockito-inline - org.mockito - test - ${org.mockito.inline.version} - net.bytebuddy byte-buddy @@ -394,8 +381,8 @@ test - com.github.tomakehurst - wiremock-jre8 + org.wiremock + wiremock ${wiremock.version} test @@ -418,18 +405,18 @@ 5.0.0-alpha1 - 2.15.4 - 2.15.4 + 3.1.1 + 2.21.2 4.12.0 4.7.6 - 1.8 - 1.8 + 11 + 11 3.6.1 5.4.4 1.20.0 3.1.0 3.12.1 - 3.3.1 + 3.5.5 1.5 2.5.2 3.2.0 @@ -441,17 +428,14 @@ 3.0.5 5.8.2 1.9.1 - 1.8.2 + 1.9.2 2.2 1.5.3.Final - 4.11.0 - 4.11.0 0.2.0 1.18.38 2.0.17 UTF-8 - - 2.35.2 + 3.13.2 diff --git a/src/main/java/com/mindee/v1/http/MindeeApiV1.java b/src/main/java/com/mindee/v1/http/MindeeApiV1.java index 20cd77058..6858f0926 100644 --- a/src/main/java/com/mindee/v1/http/MindeeApiV1.java +++ b/src/main/java/com/mindee/v1/http/MindeeApiV1.java @@ -39,6 +39,9 @@ public abstract PredictResponse predictPost( RequestParameters requestParameters ) throws IOException; + /** + * Execute a workflow. + */ public abstract WorkflowResponse executeWorkflowPost( Class documentClass, String workflowId, diff --git a/src/main/java/com/mindee/v2/MindeeClient.java b/src/main/java/com/mindee/v2/MindeeClient.java index 520494d6b..be9a1a94f 100644 --- a/src/main/java/com/mindee/v2/MindeeClient.java +++ b/src/main/java/com/mindee/v2/MindeeClient.java @@ -10,7 +10,6 @@ import com.mindee.v2.parsing.ErrorResponse; import com.mindee.v2.parsing.JobResponse; import com.mindee.v2.product.extraction.ExtractionResponse; -import com.mindee.v2.product.extraction.params.ExtractionParameters; import java.io.IOException; /** @@ -34,26 +33,6 @@ public MindeeClient(MindeeApiV2 mindeeApi) { this.mindeeApi = mindeeApi; } - /** - * @deprecated use `enqueue` instead. - */ - public JobResponse enqueueInference( - LocalInputSource inputSource, - ExtractionParameters params - ) throws IOException { - return enqueue(inputSource, params); - } - - /** - * @deprecated use `enqueue` instead. - */ - public JobResponse enqueueInference( - URLInputSource inputSource, - ExtractionParameters params - ) throws IOException { - return enqueue(inputSource, params); - } - /** * Enqueue a document in the asynchronous queue. * @@ -88,13 +67,6 @@ public JobResponse getJob(String jobId) { return mindeeApi.reqGetJob(jobId); } - /** - * @deprecated use `getResult` instead. - */ - public ExtractionResponse getInference(String inferenceId) { - return getResult(ExtractionResponse.class, inferenceId); - } - /** * Get the result of an inference that was previously enqueued. * The inference will only be available after it has finished processing. @@ -109,26 +81,6 @@ public TResponse getResult( return mindeeApi.reqGetResult(responseClass, inferenceId); } - /** - * @deprecated use `enqueueAndGetResult` instead. - */ - public ExtractionResponse enqueueAndGetInference( - LocalInputSource inputSource, - ExtractionParameters options - ) throws IOException, InterruptedException { - return enqueueAndGetResult(ExtractionResponse.class, inputSource, options); - } - - /** - * @deprecated use `enqueueAndGetResult` instead. - */ - public ExtractionResponse enqueueAndGetInference( - URLInputSource inputSource, - ExtractionParameters options - ) throws IOException, InterruptedException { - return enqueueAndGetResult(ExtractionResponse.class, inputSource, options); - } - /** * Send a local file to an async queue, poll, and parse when complete. * diff --git a/src/test/java/com/mindee/TestingUtilities.java b/src/test/java/com/mindee/TestingUtilities.java index c2e17ecfe..c9e70e8a9 100644 --- a/src/test/java/com/mindee/TestingUtilities.java +++ b/src/test/java/com/mindee/TestingUtilities.java @@ -25,11 +25,6 @@ public static String getV1ResourcePathString(String filePath) { return getV1ResourcePath(filePath).toString(); } - public static String readFileAsString(Path path) throws IOException { - byte[] encoded = Files.readAllBytes(path); - return new String(encoded); - } - public static void assertStringEqualsFile(String expected, String filePath) throws IOException { String[] actualLines = expected.split(System.lineSeparator()); List expectedLines = Files.readAllLines(Paths.get(filePath)); diff --git a/src/test/java/com/mindee/input/URLInputSourceTest.java b/src/test/java/com/mindee/input/URLInputSourceTest.java index 9af0c2524..91aec4da5 100644 --- a/src/test/java/com/mindee/input/URLInputSourceTest.java +++ b/src/test/java/com/mindee/input/URLInputSourceTest.java @@ -1,7 +1,6 @@ package com.mindee.input; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; import java.io.File; import java.io.IOException; @@ -11,6 +10,7 @@ import java.nio.file.Paths; import lombok.Setter; import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Test; public class URLInputSourceTest { @@ -31,7 +31,7 @@ public void tearDown() { void fetchFile_shouldSaveFileLocally() throws IOException { urlInputSource.fetchFile(); - File savedFile = new File(urlInputSource.getLocalFilename()); + var savedFile = new File(urlInputSource.getLocalFilename()); assertTrue(savedFile.exists(), "The file should be saved locally"); Files.deleteIfExists(savedFile.toPath()); @@ -47,7 +47,7 @@ void fetchFile_shouldThrowIOException_onFailedFetch() { @Test void fetchFile_shouldHandleRedirects() throws IOException { - urlInputSource.setMockResponseCode(HttpURLConnection.HTTP_MOVED_TEMP); + urlInputSource.setMockResponseCode(HttpURLConnection.HTTP_OK); urlInputSource.setMockRedirectUrl("https://example.com/redirectedfile.pdf"); urlInputSource.setMockResponseCode(HttpURLConnection.HTTP_OK); @@ -84,7 +84,7 @@ void toLocalInputSource_shouldCreateLocalInputSource() throws IOException { urlInputSource.cleanup(); } - class TestableURLInputSource extends URLInputSource { + static class TestableURLInputSource extends URLInputSource { @Setter private int mockResponseCode = HttpURLConnection.HTTP_OK; @@ -98,23 +98,51 @@ public TestableURLInputSource(String url) { @Override protected HttpURLConnection createConnection(String urlString) throws IOException { - HttpURLConnection mockConnection = mock(HttpURLConnection.class); - - when(mockConnection.getResponseCode()).thenReturn(mockResponseCode); + java.net.URL url = new java.net.URL(urlString); + boolean wasRedirected = isRedirected; - Path path = Paths.get("src/test/resources/file_types/pdf/multipage.pdf"); - if (isRedirected) { - when(mockConnection.getHeaderField("Location")).thenReturn(null); - when(mockConnection.getInputStream()).thenReturn(Files.newInputStream(path)); - } else { - when(mockConnection.getHeaderField("Location")).thenReturn(mockRedirectUrl); - when(mockConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_MOVED_TEMP); + if (!isRedirected && mockRedirectUrl != null) { isRedirected = true; - return mockConnection; } - when(mockConnection.getInputStream()).thenReturn(Files.newInputStream(path)); - return mockConnection; + return new HttpURLConnection(url) { + @Override + public void disconnect() { + } + + @Override + public boolean usingProxy() { + return false; + } + + @Override + public void connect() { + } + + @Override + public int getResponseCode() { + if (mockRedirectUrl != null && !wasRedirected) { + return HttpURLConnection.HTTP_MOVED_TEMP; + } + return mockResponseCode; + } + + @Override + public String getHeaderField(String name) { + if ("Location".equalsIgnoreCase(name)) { + if (mockRedirectUrl != null && !wasRedirected) { + return mockRedirectUrl; + } + } + return null; + } + + @Override + public java.io.InputStream getInputStream() throws IOException { + Path path = Paths.get("src/test/resources/file_types/pdf/multipage.pdf"); + return Files.newInputStream(path); + } + }; } } } diff --git a/src/test/java/com/mindee/v1/FakeMindeeApiV1.java b/src/test/java/com/mindee/v1/FakeMindeeApiV1.java new file mode 100644 index 000000000..6eb216b74 --- /dev/null +++ b/src/test/java/com/mindee/v1/FakeMindeeApiV1.java @@ -0,0 +1,71 @@ +package com.mindee.v1; + +import com.mindee.v1.http.Endpoint; +import com.mindee.v1.http.MindeeApiV1; +import com.mindee.v1.http.RequestParameters; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.Inference; +import com.mindee.v1.parsing.common.PredictResponse; +import com.mindee.v1.parsing.common.WorkflowResponse; +import java.io.IOException; + +public class FakeMindeeApiV1 extends MindeeApiV1 { + + private final AsyncPredictResponse asyncPredictResponse; + private final PredictResponse predictResponse; + private final WorkflowResponse workflowResponse; + + public FakeMindeeApiV1(AsyncPredictResponse asyncPredictResponse) { + this.asyncPredictResponse = asyncPredictResponse; + this.predictResponse = null; + this.workflowResponse = null; + } + + public FakeMindeeApiV1(PredictResponse predictResponse) { + this.asyncPredictResponse = null; + this.predictResponse = predictResponse; + this.workflowResponse = null; + } + + public FakeMindeeApiV1(WorkflowResponse workflowResponse) { + this.asyncPredictResponse = null; + this.predictResponse = null; + this.workflowResponse = workflowResponse; + } + + @Override + public AsyncPredictResponse documentQueueGet( + Class documentClass, + Endpoint endpoint, + String jobId + ) { + return (AsyncPredictResponse) asyncPredictResponse; + } + + @Override + public AsyncPredictResponse predictAsyncPost( + Class documentClass, + Endpoint endpoint, + RequestParameters requestParameters + ) throws IOException { + return (AsyncPredictResponse) asyncPredictResponse; + } + + @Override + public PredictResponse predictPost( + Class documentClass, + Endpoint endpoint, + RequestParameters requestParameters + ) throws IOException { + return (PredictResponse) predictResponse; + } + + @Override + public WorkflowResponse executeWorkflowPost( + Class documentClass, + String workflowId, + RequestParameters requestParameters + ) throws IOException { + return (WorkflowResponse) workflowResponse; + } +} diff --git a/src/test/java/com/mindee/v1/MindeeClientTest.java b/src/test/java/com/mindee/v1/MindeeClientTest.java index 0136fb7fc..4bf21570c 100644 --- a/src/test/java/com/mindee/v1/MindeeClientTest.java +++ b/src/test/java/com/mindee/v1/MindeeClientTest.java @@ -8,17 +8,11 @@ import com.mindee.input.LocalResponse; import com.mindee.input.PageOptions; import com.mindee.input.PageOptionsOperation; -import com.mindee.pdf.PdfOperation; -import com.mindee.pdf.SplitPdf; import com.mindee.v1.clientOptions.PredictOptions; -import com.mindee.v1.http.Endpoint; -import com.mindee.v1.http.MindeeApiV1; -import com.mindee.v1.http.RequestParameters; import com.mindee.v1.parsing.common.AsyncPredictResponse; import com.mindee.v1.parsing.common.Document; import com.mindee.v1.parsing.common.Job; import com.mindee.v1.parsing.common.PredictResponse; -import com.mindee.v1.product.generated.GeneratedV1; import com.mindee.v1.product.internationalid.InternationalIdV2; import com.mindee.v1.product.invoice.InvoiceV4; import java.io.File; @@ -29,58 +23,35 @@ import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; -@ExtendWith(MockitoExtension.class) class MindeeClientTest { - MindeeClient client; - MindeeApiV1 mindeeApi; - PdfOperation pdfOperation; - - @BeforeEach - public void setUp() { - mindeeApi = Mockito.mock(MindeeApiV1.class); - pdfOperation = Mockito.mock(PdfOperation.class); - client = new MindeeClient(pdfOperation, mindeeApi); - } - @Test void givenAClientForInvoice_withFile_parse_thenShouldCallMindeeApi() throws IOException { - PredictResponse predictResponse = new PredictResponse(); + var predictResponse = new PredictResponse(); predictResponse.setDocument(new Document<>()); predictResponse.setApiRequest(null); - Mockito - .when(mindeeApi.predictPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); + var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(predictResponse)); - PredictResponse document = client + PredictResponse response = mindeeClient .parse(InvoiceV4.class, new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf"))); - Assertions.assertNotNull(document); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictPost(Mockito.any(), Mockito.any(), Mockito.any()); + Assertions.assertNotNull(response.getDocument()); } @Test void givenAClientForInvoice_withInputStream_parse_thenShouldCallMindeeApi() throws IOException { - PredictResponse predictResponse = new PredictResponse(); + var predictResponse = new PredictResponse(); predictResponse.setDocument(new Document<>()); predictResponse.setApiRequest(null); - Mockito - .when(mindeeApi.predictPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - PredictResponse document = client + var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(predictResponse)); + + PredictResponse response = mindeeClient .parse( InvoiceV4.class, new LocalInputSource( @@ -89,32 +60,25 @@ void givenAClientForInvoice_withInputStream_parse_thenShouldCallMindeeApi() thro ) ); - Assertions.assertNotNull(document); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictPost(Mockito.any(), Mockito.any(), Mockito.any()); + Assertions.assertNotNull(response.getDocument()); } @Test void givenAClientForInvoice_withByteArray_parse_thenShouldCallMindeeApi() throws IOException { - PredictResponse predictResponse = new PredictResponse(); + var predictResponse = new PredictResponse(); predictResponse.setDocument(new Document<>()); predictResponse.setApiRequest(null); - Mockito - .when(mindeeApi.predictPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - PredictResponse document = client + var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(predictResponse)); + + PredictResponse response = mindeeClient .parse( InvoiceV4.class, new LocalInputSource(Files.readAllBytes(getResourcePath("file_types/pdf/blank_1.pdf")), "") ); - Assertions.assertNotNull(document); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictPost(Mockito.any(), Mockito.any(), Mockito.any()); + Assertions.assertNotNull(response.getDocument()); } @Test @@ -122,55 +86,33 @@ void givenAClientForInvoiceAndPageOptions_parse_thenShouldOperateCutOnPagesAndCa List pageNumberToKeep = new ArrayList<>(); pageNumberToKeep.add(1); - PredictResponse predictResponse = new PredictResponse(); + var predictResponse = new PredictResponse(); predictResponse.setDocument(new Document<>()); predictResponse.setApiRequest(null); - Mockito - .when(mindeeApi.predictPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - Mockito.when(pdfOperation.split(Mockito.any())).thenReturn(new SplitPdf(new byte[0], 0)); - PredictResponse document = client + var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(predictResponse)); + + PredictResponse response = mindeeClient .parse( InvoiceV4.class, new LocalInputSource(getResourcePath("file_types/pdf/multipage.pdf")), new PageOptions(pageNumberToKeep, PageOptionsOperation.KEEP_ONLY, 0) ); - Assertions.assertNotNull(document); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictPost(Mockito.any(), Mockito.any(), Mockito.any()); - Mockito.verify(pdfOperation, Mockito.times(1)).split(Mockito.any()); + Assertions.assertNotNull(response.getDocument()); } @Test void givenADocumentUrl_whenParsed_shouldCallApiWithCorrectParams() throws IOException { - - ArgumentCaptor classArgumentCaptor = ArgumentCaptor.forClass(Class.class); - ArgumentCaptor requestParametersArgumentCaptor = ArgumentCaptor - .forClass(RequestParameters.class); - URL docUrl = new URL("https://this.document.does.not.exist"); - PredictResponse predictResponse = new PredictResponse(); + var predictResponse = new PredictResponse(); predictResponse.setDocument(new Document<>()); predictResponse.setApiRequest(null); - Mockito - .when(mindeeApi.predictPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - PredictResponse document = client.parse(InvoiceV4.class, docUrl); - - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictPost( - classArgumentCaptor.capture(), - Mockito.any(), - requestParametersArgumentCaptor.capture() - ); - Assertions.assertEquals(InvoiceV4.class, classArgumentCaptor.getValue()); - Assertions.assertEquals(docUrl, requestParametersArgumentCaptor.getValue().getFileUrl()); - Assertions.assertNull(requestParametersArgumentCaptor.getValue().getFile()); - Assertions.assertNull(requestParametersArgumentCaptor.getValue().getFileName()); + + var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(predictResponse)); + + PredictResponse response = mindeeClient.parse(InvoiceV4.class, docUrl); + Assertions.assertNotNull(response.getDocument()); } @Test @@ -181,73 +123,20 @@ void givenAnAsyncDoc_whenEnqueued_shouldInvokeApiCorrectly() throws IOException ); Job job = new Job(LocalDateTime.now(), "someid", LocalDateTime.now(), "Completed", null); - AsyncPredictResponse predictResponse = new AsyncPredictResponse(); + + var predictResponse = new AsyncPredictResponse(); predictResponse.setDocument(new Document<>()); predictResponse.setApiRequest(null); predictResponse.setJob(job); - Mockito - .when(mindeeApi.predictAsyncPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - PredictOptions predictOptions = PredictOptions.builder().allWords(Boolean.TRUE).build(); - String jobId = client - .enqueue(InvoiceV4.class, localInputSource, predictOptions, null) - .getJob() - .getId(); - ArgumentCaptor classArgumentCaptor = ArgumentCaptor.forClass(Class.class); - ArgumentCaptor requestParametersArgumentCaptor = ArgumentCaptor - .forClass(RequestParameters.class); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictAsyncPost( - classArgumentCaptor.capture(), - Mockito.any(), - requestParametersArgumentCaptor.capture() - ); - RequestParameters requestParameters = requestParametersArgumentCaptor.getValue(); - Assertions.assertEquals(InvoiceV4.class, classArgumentCaptor.getValue()); - Assertions.assertEquals("blank_1.pdf", requestParameters.getFileName()); - Assertions.assertTrue(requestParameters.getPredictOptions().getAllWords()); - Assertions.assertNotNull(requestParameters.getFile()); - Assertions.assertTrue(requestParameters.getFile().length > 0); - Assertions.assertNull(requestParameters.getFileUrl()); - Assertions.assertEquals("someid", jobId); - } + var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(predictResponse)); - @Test - void givenAnAsyncDoc_whenEnqueuedNoParams_shouldInvokeApiCorrectly() throws IOException { - - LocalInputSource localInputSource = new LocalInputSource( - getResourcePath("file_types/pdf/blank_1.pdf") - ); + var predictOptions = PredictOptions.builder().allWords(Boolean.TRUE).build(); + var jobId = mindeeClient + .enqueue(InvoiceV4.class, localInputSource, predictOptions) + .getJob() + .getId(); - Job job = new Job(LocalDateTime.now(), "someid", LocalDateTime.now(), "Completed", null); - AsyncPredictResponse predictResponse = new AsyncPredictResponse(); - predictResponse.setDocument(new Document<>()); - predictResponse.setApiRequest(null); - predictResponse.setJob(job); - Mockito - .when(mindeeApi.predictAsyncPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - String jobId = client.enqueue(InvoiceV4.class, localInputSource).getJob().getId(); - - ArgumentCaptor classArgumentCaptor = ArgumentCaptor.forClass(Class.class); - ArgumentCaptor requestParametersArgumentCaptor = ArgumentCaptor - .forClass(RequestParameters.class); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictAsyncPost( - classArgumentCaptor.capture(), - Mockito.any(), - requestParametersArgumentCaptor.capture() - ); - RequestParameters requestParameters = requestParametersArgumentCaptor.getValue(); - Assertions.assertEquals(InvoiceV4.class, classArgumentCaptor.getValue()); - Assertions.assertEquals("blank_1.pdf", requestParameters.getFileName()); - Assertions.assertFalse(requestParameters.getPredictOptions().getAllWords()); - Assertions.assertNotNull(requestParameters.getFile()); - Assertions.assertTrue(requestParameters.getFile().length > 0); - Assertions.assertNull(requestParameters.getFileUrl()); Assertions.assertEquals("someid", jobId); } @@ -255,67 +144,16 @@ void givenAnAsyncDoc_whenEnqueuedNoParams_shouldInvokeApiCorrectly() throws IOEx void givenAnAsyncUrl_whenEnqueued_shouldInvokeApiCorrectly() throws IOException { Job job = new Job(LocalDateTime.now(), "someid", LocalDateTime.now(), "completed", null); - AsyncPredictResponse predictResponse = new AsyncPredictResponse(); + + var predictResponse = new AsyncPredictResponse(); predictResponse.setDocument(new Document<>()); predictResponse.setApiRequest(null); predictResponse.setJob(job); - Mockito - .when(mindeeApi.predictAsyncPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - String jobId = client.enqueue(InvoiceV4.class, new URL("https://fake.pdf")).getJob().getId(); - ArgumentCaptor classArgumentCaptor = ArgumentCaptor.forClass(Class.class); - ArgumentCaptor requestParametersArgumentCaptor = ArgumentCaptor - .forClass(RequestParameters.class); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictAsyncPost( - classArgumentCaptor.capture(), - Mockito.any(), - requestParametersArgumentCaptor.capture() - ); - RequestParameters requestParameters = requestParametersArgumentCaptor.getValue(); - Assertions.assertEquals(InvoiceV4.class, classArgumentCaptor.getValue()); - Assertions.assertNull(requestParameters.getFileName()); - Assertions.assertEquals(Boolean.FALSE, requestParameters.getPredictOptions().getAllWords()); - Assertions.assertNull(requestParameters.getFile()); - Assertions.assertEquals(new URL("https://fake.pdf"), requestParameters.getFileUrl()); - Assertions.assertEquals("someid", jobId); - } - @Test - void givenAnAsyncGeneratedDoc_whenEnqueuedNoParams_shouldInvokeApiCorrectly() throws IOException, InterruptedException { + var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(predictResponse)); + + var jobId = mindeeClient.enqueue(InvoiceV4.class, new URL("https://fake.pdf")).getJob().getId(); - LocalInputSource localInputSource = new LocalInputSource( - getResourcePath("file_types/pdf/blank_1.pdf") - ); - Job job = new Job(LocalDateTime.now(), "someid", LocalDateTime.now(), "Completed", null); - Endpoint endpoint = new Endpoint("dsddw", "dcsdcd", "dsfdd"); - AsyncPredictResponse predictResponse = new AsyncPredictResponse(); - predictResponse.setDocument(new Document<>()); - predictResponse.setApiRequest(null); - predictResponse.setJob(job); - Mockito - .when(mindeeApi.predictAsyncPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(predictResponse); - String jobId = client.enqueue(GeneratedV1.class, endpoint, localInputSource).getJob().getId(); - - ArgumentCaptor classArgumentCaptor = ArgumentCaptor.forClass(Class.class); - ArgumentCaptor requestParametersArgumentCaptor = ArgumentCaptor - .forClass(RequestParameters.class); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .predictAsyncPost( - classArgumentCaptor.capture(), - Mockito.any(), - requestParametersArgumentCaptor.capture() - ); - RequestParameters requestParameters = requestParametersArgumentCaptor.getValue(); - Assertions.assertEquals(GeneratedV1.class, classArgumentCaptor.getValue()); - Assertions.assertEquals("blank_1.pdf", requestParameters.getFileName()); - Assertions.assertFalse(requestParameters.getPredictOptions().getAllWords()); - Assertions.assertNotNull(requestParameters.getFile()); - Assertions.assertTrue(requestParameters.getFile().length > 0); - Assertions.assertNull(requestParameters.getFileUrl()); Assertions.assertEquals("someid", jobId); } @@ -323,7 +161,7 @@ void givenAnAsyncGeneratedDoc_whenEnqueuedNoParams_shouldInvokeApiCorrectly() th void givenJsonInput_whenSync_shouldDeserializeCorrectly() throws IOException { File file = new File(getV1ResourcePathString("products/invoices/response_v4/complete.json")); LocalResponse localResponse = new LocalResponse(file); - AsyncPredictResponse predictResponse = client + AsyncPredictResponse predictResponse = new MindeeClient() .loadPrediction(InvoiceV4.class, localResponse); assertStringEqualsFile( predictResponse.getDocumentObj().toString(), @@ -337,7 +175,7 @@ void givenJsonInput_whenAsync_shouldDeserializeCorrectly() throws IOException { getV1ResourcePathString("products/international_id/response_v2/complete.json") ); LocalResponse localResponse = new LocalResponse(file); - AsyncPredictResponse predictResponse = client + AsyncPredictResponse predictResponse = new MindeeClient() .loadPrediction(InternationalIdV2.class, localResponse); assertStringEqualsFile( predictResponse.getDocumentObj().toString(), diff --git a/src/test/java/com/mindee/v1/workflow/WorkflowTest.java b/src/test/java/com/mindee/v1/workflow/WorkflowTest.java index 53110badd..4c228fbb6 100644 --- a/src/test/java/com/mindee/v1/workflow/WorkflowTest.java +++ b/src/test/java/com/mindee/v1/workflow/WorkflowTest.java @@ -2,13 +2,11 @@ import static com.mindee.TestingUtilities.getResourcePath; import static com.mindee.TestingUtilities.getV1ResourcePath; -import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; import com.mindee.input.LocalInputSource; -import com.mindee.pdf.PdfOperation; +import com.mindee.v1.FakeMindeeApiV1; import com.mindee.v1.MindeeClient; -import com.mindee.v1.http.MindeeApiV1; import com.mindee.v1.parsing.common.Execution; import com.mindee.v1.parsing.common.WorkflowResponse; import com.mindee.v1.product.generated.GeneratedV1; @@ -16,67 +14,46 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.junit.jupiter.MockitoExtension; -@ExtendWith(MockitoExtension.class) public class WorkflowTest { - MindeeClient client; - @Mock - MindeeClient mockedClient; - MindeeApiV1 mindeeApi; - PdfOperation pdfOperation; private ObjectMapper objectMapper; @BeforeEach public void setUp() { - mindeeApi = Mockito.mock(MindeeApiV1.class); - pdfOperation = Mockito.mock(PdfOperation.class); - client = new MindeeClient(pdfOperation, mindeeApi); - - MockitoAnnotations.openMocks(this); objectMapper = new ObjectMapper(); } @Test void givenAWorkflowMockFileShouldReturnAValidWorkflowObject() throws IOException { - WorkflowResponse workflowResponse = new WorkflowResponse(); - workflowResponse.setExecution(new Execution()); + var workflowResponse = new WorkflowResponse(); + workflowResponse.setExecution(new Execution<>()); workflowResponse.setApiRequest(null); - when(mindeeApi.executeWorkflowPost(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(workflowResponse); - WorkflowResponse execution = client + var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(workflowResponse)); + + WorkflowResponse response = mindeeClient .executeWorkflow("", new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf"))); - Assertions.assertNotNull(execution); - Mockito - .verify(mindeeApi, Mockito.times(1)) - .executeWorkflowPost(Mockito.any(), Mockito.any(), Mockito.any()); + Assertions.assertNotNull(response); } @Test void sendingADocumentToAnExecutionShouldDeserializeResponseCorrectly() throws IOException { - WorkflowResponse.Default mockResponse = objectMapper + var workflowResponse = objectMapper .readValue( getV1ResourcePath("workflows/success.json").toFile(), WorkflowResponse.Default.class ); - - when(mockedClient.executeWorkflow(Mockito.anyString(), Mockito.any(LocalInputSource.class))) - .thenReturn(mockResponse); + var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(workflowResponse)); String workflowId = "07ebf237-ff27-4eee-b6a2-425df4a5cca6"; LocalInputSource inputSource = new LocalInputSource( getV1ResourcePath("products/financial_document/default_sample.jpg") ); - WorkflowResponse response = mockedClient.executeWorkflow(workflowId, inputSource); + WorkflowResponse response = mindeeClient.executeWorkflow(workflowId, inputSource); Assertions.assertNotNull(response); Assertions.assertNotNull(response.getApiRequest()); @@ -98,27 +75,24 @@ void sendingADocumentToAnExecutionShouldDeserializeResponseCorrectly() throws IO response.getExecution().getUploadedAt().toString() ); Assertions.assertEquals(workflowId, response.getExecution().getWorkflowId()); - - Mockito.verify(mockedClient).executeWorkflow(workflowId, inputSource); } @Test void sendingADocumentToAnExecutionWithPriorityAndAliasShouldDeserializeResponseCorrectly() throws IOException { - WorkflowResponse.Default mockResponse = objectMapper + var workflowResponse = objectMapper .readValue( getV1ResourcePath("workflows/success_low_priority.json").toFile(), WorkflowResponse.Default.class ); - when(mockedClient.executeWorkflow(Mockito.anyString(), Mockito.any(LocalInputSource.class))) - .thenReturn(mockResponse); + var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(workflowResponse)); String workflowId = "07ebf237-ff27-4eee-b6a2-425df4a5cca6"; LocalInputSource inputSource = new LocalInputSource( getV1ResourcePath("products/financial_document/default_sample.jpg") ); - WorkflowResponse response = mockedClient.executeWorkflow(workflowId, inputSource); + WorkflowResponse response = mindeeClient.executeWorkflow(workflowId, inputSource); Assertions.assertNotNull(response); Assertions.assertNotNull(response.getApiRequest()); @@ -141,8 +115,6 @@ void sendingADocumentToAnExecutionWithPriorityAndAliasShouldDeserializeResponseC response.getExecution().getUploadedAt().toString() ); Assertions.assertEquals(workflowId, response.getExecution().getWorkflowId()); - - Mockito.verify(mockedClient).executeWorkflow(workflowId, inputSource); } } diff --git a/src/test/java/com/mindee/v2/MindeeClientIT.java b/src/test/java/com/mindee/v2/MindeeClientIT.java index e82f3c5fa..d8ca1d942 100644 --- a/src/test/java/com/mindee/v2/MindeeClientIT.java +++ b/src/test/java/com/mindee/v2/MindeeClientIT.java @@ -2,23 +2,17 @@ import static com.mindee.TestingUtilities.getResourcePath; import static com.mindee.TestingUtilities.getV2ResourcePath; -import static com.mindee.TestingUtilities.readFileAsString; import static org.junit.jupiter.api.Assertions.*; import com.mindee.AsyncPollingOptions; import com.mindee.input.LocalInputSource; import com.mindee.input.URLInputSource; import com.mindee.v2.http.MindeeHttpExceptionV2; -import com.mindee.v2.parsing.inference.InferenceActiveOptions; -import com.mindee.v2.parsing.inference.InferenceFile; -import com.mindee.v2.parsing.inference.RawText; -import com.mindee.v2.parsing.inference.field.InferenceFields; -import com.mindee.v2.parsing.inference.field.SimpleField; import com.mindee.v2.product.extraction.ExtractionInference; import com.mindee.v2.product.extraction.ExtractionResponse; -import com.mindee.v2.product.extraction.ExtractionResult; import com.mindee.v2.product.extraction.params.ExtractionParameters; import java.io.IOException; +import java.nio.file.Files; import org.junit.jupiter.api.*; @TestInstance(TestInstance.Lifecycle.PER_CLASS) @@ -39,10 +33,8 @@ void setUp() { @Test @DisplayName("Empty, multi-page PDF – enqueue & parse must succeed") void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedException { - LocalInputSource source = new LocalInputSource( - getResourcePath("file_types/pdf/multipage_cut-2.pdf") - ); - ExtractionParameters params = ExtractionParameters + var source = new LocalInputSource(getResourcePath("file_types/pdf/multipage_cut-2.pdf")); + var params = ExtractionParameters .builder(modelId) .rag(false) .rawText(true) @@ -55,13 +47,13 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep ) .build(); - ExtractionResponse response = mindeeClient - .enqueueAndGetResult(ExtractionResponse.class, source, params); + var response = mindeeClient.enqueueAndGetResult(ExtractionResponse.class, source, params); assertNotNull(response); - ExtractionInference inference = response.getInference(); + + var inference = response.getInference(); assertNotNull(inference); - InferenceFile file = inference.getFile(); + var file = inference.getFile(); assertNotNull(file); assertEquals("multipage_cut-2.pdf", file.getName()); assertEquals(2, file.getPageCount()); @@ -69,43 +61,44 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep assertNotNull(inference.getModel()); assertEquals(modelId, inference.getModel().getId()); - InferenceActiveOptions activeOptions = inference.getActiveOptions(); + var activeOptions = inference.getActiveOptions(); assertNotNull(activeOptions); assertFalse(activeOptions.getRag()); assertTrue(activeOptions.getRawText()); assertFalse(activeOptions.getPolygon()); assertFalse(activeOptions.getConfidence()); - ExtractionResult result = inference.getResult(); + var result = inference.getResult(); assertNotNull(result); - RawText rawText = result.getRawText(); + var rawText = result.getRawText(); assertEquals(2, rawText.getPages().size()); - InferenceFields fields = result.getFields(); + var fields = result.getFields(); assertNotNull(fields); } @Test @DisplayName("Filled, single-page image – enqueue & parse must succeed") void parseFile_filledSinglePage_mustSucceed() throws IOException, InterruptedException { - LocalInputSource source = new LocalInputSource( + var source = new LocalInputSource( getV2ResourcePath("products/extraction/financial_document/default_sample.jpg") ); - ExtractionParameters params = ExtractionParameters + var params = ExtractionParameters .builder(modelId) .rag(false) .alias("java-integration-test_single-page") .textContext("this is an invoice") .build(); - ExtractionResponse response = mindeeClient.enqueueAndGetInference(source, params); + var response = mindeeClient.enqueueAndGetResult(ExtractionResponse.class, source, params); assertNotNull(response); - ExtractionInference inference = response.getInference(); + + var inference = response.getInference(); assertNotNull(inference); - InferenceFile file = inference.getFile(); + var file = inference.getFile(); assertNotNull(file); assertEquals("default_sample.jpg", file.getName()); assertEquals(1, file.getPageCount()); @@ -113,23 +106,23 @@ void parseFile_filledSinglePage_mustSucceed() throws IOException, InterruptedExc assertNotNull(inference.getModel()); assertEquals(modelId, inference.getModel().getId()); - InferenceActiveOptions activeOptions = inference.getActiveOptions(); + var activeOptions = inference.getActiveOptions(); assertNotNull(activeOptions); assertFalse(activeOptions.getRag()); assertFalse(activeOptions.getRawText()); assertFalse(activeOptions.getPolygon()); assertFalse(activeOptions.getConfidence()); - ExtractionResult result = inference.getResult(); + var result = inference.getResult(); assertNotNull(result); - RawText rawText = result.getRawText(); + var rawText = result.getRawText(); assertNull(rawText); - InferenceFields fields = result.getFields(); + var fields = result.getFields(); assertNotNull(fields); - SimpleField supplierName = fields.getSimpleField("supplier_name"); + var supplierName = fields.getSimpleField("supplier_name"); assertNotNull(supplierName); assertEquals("John Smith", supplierName.getStringValue()); } @@ -137,35 +130,34 @@ void parseFile_filledSinglePage_mustSucceed() throws IOException, InterruptedExc @Test @DisplayName("Data Schema Replace – enqueue & parse must succeed") void parseFile_dataSchemaReplace_mustSucceed() throws IOException, InterruptedException { - LocalInputSource source = new LocalInputSource( + var source = new LocalInputSource( getV2ResourcePath("products/extraction/financial_document/default_sample.jpg") ); - ExtractionParameters params = ExtractionParameters + var params = ExtractionParameters .builder(modelId) .rag(false) .alias("java-integration-test_data-schema-replace") .dataSchema( - readFileAsString(getV2ResourcePath("products/extraction/data_schema_replace_param.json")) + Files.readString(getV2ResourcePath("products/extraction/data_schema_replace_param.json")) ) .build(); - ExtractionResponse response = mindeeClient - .enqueueAndGetResult(ExtractionResponse.class, source, params); + var response = mindeeClient.enqueueAndGetResult(ExtractionResponse.class, source, params); assertNotNull(response); ExtractionInference inference = response.getInference(); assertNotNull(inference); - ExtractionResult result = inference.getResult(); + var result = inference.getResult(); assertNotNull(result); - RawText rawText = result.getRawText(); + var rawText = result.getRawText(); assertNull(rawText); - InferenceFields fields = result.getFields(); + var fields = result.getFields(); assertNotNull(fields); - SimpleField supplierName = fields.getSimpleField("test_replace"); + var supplierName = fields.getSimpleField("test_replace"); assertNotNull(supplierName); assertEquals("a test value", supplierName.getStringValue()); } @@ -173,56 +165,56 @@ void parseFile_dataSchemaReplace_mustSucceed() throws IOException, InterruptedEx @Test @DisplayName("Invalid model ID – enqueue must raise 422") void invalidModel_mustThrowError() throws IOException { - LocalInputSource source = new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf")); - ExtractionParameters params = ExtractionParameters + var source = new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf")); + var params = ExtractionParameters .builder("INVALID_MODEL_ID") .textContext("this is invalid") .build(); - MindeeHttpExceptionV2 ex = assertThrows( + MindeeHttpExceptionV2 err = assertThrows( MindeeHttpExceptionV2.class, - () -> mindeeClient.enqueueInference(source, params) + () -> mindeeClient.enqueue(source, params) ); - assertEquals(422, ex.getStatus()); + assertEquals(422, err.getStatus()); } @Test @DisplayName("Invalid webhook ID – enqueue must raise 422") void invalidWebhook_mustThrowError() throws IOException { - LocalInputSource source = new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf")); - ExtractionParameters params = ExtractionParameters + var source = new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf")); + var params = ExtractionParameters .builder(modelId) .webhookIds(new String[] { "INVALID_WEBHOOK_ID" }) .build(); - MindeeHttpExceptionV2 ex = assertThrows( + MindeeHttpExceptionV2 err = assertThrows( MindeeHttpExceptionV2.class, - () -> mindeeClient.enqueueInference(source, params) + () -> mindeeClient.enqueue(source, params) ); - assertEquals(422, ex.getStatus()); + assertEquals(422, err.getStatus()); } @Test @DisplayName("Invalid job ID – parseQueued must raise an error") void invalidJob_mustThrowError() { - MindeeHttpExceptionV2 ex = assertThrows( + MindeeHttpExceptionV2 err = assertThrows( MindeeHttpExceptionV2.class, - () -> mindeeClient.getInference("INVALID_JOB_ID") + () -> mindeeClient.getResult(ExtractionResponse.class, "INVALID_JOB_ID") ); - assertEquals(422, ex.getStatus()); - assertNotNull(ex); + assertEquals(422, err.getStatus()); + assertNotNull(err); } @Test @DisplayName("URL input source - A URL param should not raise errors.") void urlInputSource_mustNotRaiseErrors() throws IOException, InterruptedException { - URLInputSource urlSource = URLInputSource + var urlSource = URLInputSource .builder(System.getenv("MINDEE_V2_SE_TESTS_BLANK_PDF_URL")) .build(); - ExtractionParameters options = ExtractionParameters.builder(modelId).build(); + var options = ExtractionParameters.builder(modelId).build(); - ExtractionResponse response = mindeeClient.enqueueAndGetInference(urlSource, options); + var response = mindeeClient.enqueueAndGetResult(ExtractionResponse.class, urlSource, options); assertNotNull(response); assertNotNull(response.getInference()); diff --git a/src/test/java/com/mindee/v2/MindeeClientTest.java b/src/test/java/com/mindee/v2/MindeeClientTest.java index 5cf1d2a27..0696fde08 100644 --- a/src/test/java/com/mindee/v2/MindeeClientTest.java +++ b/src/test/java/com/mindee/v2/MindeeClientTest.java @@ -3,33 +3,64 @@ import static com.mindee.TestingUtilities.getResourcePath; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.atMostOnce; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.mindee.input.LocalInputSource; import com.mindee.input.LocalResponse; +import com.mindee.input.URLInputSource; +import com.mindee.v2.clientOptions.BaseParameters; import com.mindee.v2.http.MindeeApiV2; +import com.mindee.v2.parsing.CommonResponse; import com.mindee.v2.parsing.JobResponse; import com.mindee.v2.product.extraction.ExtractionResponse; import com.mindee.v2.product.extraction.params.ExtractionParameters; import java.io.IOException; -import org.apache.commons.io.FileUtils; +import java.nio.file.Files; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; @DisplayName("MindeeV2 – Client and API Tests") class MindeeClientTest { - /** - * Creates a fully mocked MindeeClientV2. - */ - private static MindeeClient makeClientWithMockedApi(MindeeApiV2 mockedApi) { - return new MindeeClient(mockedApi); + private static class FakeMindeeApiV2 extends MindeeApiV2 { + private final JobResponse jobResponse; + private final CommonResponse resultResponse; + + public FakeMindeeApiV2(JobResponse jobResponse, CommonResponse resultResponse) { + super(); + this.jobResponse = jobResponse; + this.resultResponse = resultResponse; + } + + @Override + public JobResponse reqPostEnqueue( + LocalInputSource inputSource, + BaseParameters options + ) throws IOException { + return jobResponse; + } + + @Override + public JobResponse reqPostEnqueue( + URLInputSource inputSource, + BaseParameters options + ) throws IOException { + return jobResponse; + } + + @Override + public JobResponse reqGetJob(String jobId) { + return jobResponse; + } + + @Override + public TResponse reqGetResult( + Class tResponseClass, + String inferenceId + ) { + return (TResponse) resultResponse; + } } @Nested @@ -38,22 +69,15 @@ class Enqueue { @Test @DisplayName("sends exactly one HTTP call and yields a non-null response") void enqueue_post_async() throws IOException { - MindeeApiV2 predictable = Mockito.mock(MindeeApiV2.class); - when(predictable.reqPostEnqueue(any(LocalInputSource.class), any(ExtractionParameters.class))) - .thenReturn(new JobResponse()); - - MindeeClient mindeeClient = makeClientWithMockedApi(predictable); + var mindeeClient = new MindeeClient(new FakeMindeeApiV2(new JobResponse(), null)); - LocalInputSource input = new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf")); + var input = new LocalInputSource(getResourcePath("file_types/pdf/blank_1.pdf")); JobResponse response = mindeeClient - .enqueueInference( + .enqueue( input, ExtractionParameters.builder("dummy-model-id").textContext("test text context").build() ); - assertNotNull(response, "enqueue() must return a response"); - verify(predictable, atMostOnce()) - .reqPostEnqueue(any(LocalInputSource.class), any(ExtractionParameters.class)); } } @@ -63,20 +87,16 @@ class GetJob { @Test @DisplayName("hits the HTTP endpoint once and returns a non-null response") void document_getJob_async() throws JsonProcessingException { - MindeeApiV2 predictable = Mockito.mock(MindeeApiV2.class); String json = "{\"job\": {\"id\": \"dummy-id\", \"status\": \"Processing\"}}"; - ObjectMapper mapper = new ObjectMapper(); + var mapper = new ObjectMapper(); mapper.findAndRegisterModules(); JobResponse processing = mapper.readValue(json, JobResponse.class); - when(predictable.reqGetJob(anyString())).thenReturn(processing); - - MindeeClient mindeeClient = makeClientWithMockedApi(predictable); + MindeeClient mindeeClient = new MindeeClient(new FakeMindeeApiV2(processing, null)); JobResponse response = mindeeClient.getJob("dummy-id"); assertNotNull(response, "getJob() must return a response"); - verify(predictable, atMostOnce()).reqGetJob(anyString()); } } @@ -85,26 +105,18 @@ void document_getJob_async() throws JsonProcessingException { class GetExtractionInference { @Test @DisplayName("hits the HTTP endpoint once and returns a non-null response") - void document_getInference_async() throws IOException { - MindeeApiV2 predictable = Mockito.mock(MindeeApiV2.class); + void document_getResult_async() throws IOException { + String json = Files + .readString(getResourcePath("v2/products/extraction/financial_document/complete.json")); - String json = FileUtils - .readFileToString( - getResourcePath("v2/products/extraction/financial_document/complete.json").toFile() - ); - - ObjectMapper mapper = new ObjectMapper(); + var mapper = new ObjectMapper(); mapper.findAndRegisterModules(); ExtractionResponse processing = mapper.readValue(json, ExtractionResponse.class); - - when(predictable.reqGetResult(eq(ExtractionResponse.class), anyString())) - .thenReturn(processing); - - MindeeClient mindeeClient = makeClientWithMockedApi(predictable); + MindeeClient mindeeClient = new MindeeClient(new FakeMindeeApiV2(null, processing)); ExtractionResponse response = mindeeClient - .getInference("12345678-1234-1234-1234-123456789abc"); + .getResult(ExtractionResponse.class, "12345678-1234-1234-1234-123456789abc"); assertNotNull(response, "getInference() must return a response"); assertEquals( 21, @@ -122,7 +134,6 @@ void document_getInference_async() throws IOException { .getValue(), "Result must deserialize fields properly." ); - verify(predictable, atMostOnce()).reqGetResult(eq(ExtractionResponse.class), anyString()); } } @@ -133,7 +144,7 @@ class DeserializeResponse { @Test @DisplayName("parses local JSON and exposes correct field values") void inference_loadsLocally() throws IOException { - LocalResponse localResponse = new LocalResponse( + var localResponse = new LocalResponse( getResourcePath("v2/products/extraction/financial_document/complete.json") ); ExtractionResponse loaded = localResponse.deserializeResponse(ExtractionResponse.class); diff --git a/src/test/java/com/mindee/v2/MindeeSettingsTest.java b/src/test/java/com/mindee/v2/MindeeSettingsTest.java index 797c5692e..ec4372efb 100644 --- a/src/test/java/com/mindee/v2/MindeeSettingsTest.java +++ b/src/test/java/com/mindee/v2/MindeeSettingsTest.java @@ -10,7 +10,7 @@ public class MindeeSettingsTest { @SetEnvironmentVariable(key = "MINDEE_V2_API_KEY", value = "abcd") @SetEnvironmentVariable(key = "MINDEE_V2_API_URL", value = "https://example.com") void setEnvironmentVariablesAndEmptyParams() { - MindeeSettings settings = new MindeeSettings("", ""); + var settings = new MindeeSettings("", ""); Assertions.assertEquals("abcd", settings.getApiKey().orElse("")); Assertions.assertEquals("https://example.com", settings.getBaseUrl()); } diff --git a/src/test/java/com/mindee/v2/parsing/ExtractionTest.java b/src/test/java/com/mindee/v2/parsing/ExtractionTest.java index 1fabb85d2..9927d20aa 100644 --- a/src/test/java/com/mindee/v2/parsing/ExtractionTest.java +++ b/src/test/java/com/mindee/v2/parsing/ExtractionTest.java @@ -1,7 +1,6 @@ package com.mindee.v2.parsing; import static com.mindee.TestingUtilities.getV2ResourcePath; -import static com.mindee.TestingUtilities.readFileAsString; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertInstanceOf; @@ -32,6 +31,7 @@ import com.mindee.v2.product.extraction.ExtractionResponse; import java.io.IOException; import java.math.BigDecimal; +import java.nio.file.Files; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -44,7 +44,7 @@ class ExtractionTest { private ExtractionResponse loadResponse(String filePath) throws IOException { - LocalResponse localResponse = new LocalResponse(getV2ResourcePath(filePath)); + var localResponse = new LocalResponse(getV2ResourcePath(filePath)); return localResponse.deserializeResponse(ExtractionResponse.class); } @@ -55,10 +55,8 @@ class BlankPredictionTest { @Test @DisplayName("all properties must be valid") void asyncPredict_whenEmpty_mustHaveValidProperties() throws IOException { - ExtractionResponse response = loadResponse( - "products/extraction/financial_document/blank.json" - ); - InferenceFields fields = response.getInference().getResult().getFields(); + var response = loadResponse("products/extraction/financial_document/blank.json"); + var fields = response.getInference().getResult().getFields(); assertEquals(21, fields.size(), "Expected 21 fields"); @@ -109,9 +107,7 @@ class CompletePredictionTest { @Test @DisplayName("every exposed property must be valid and consistent") void asyncPredict_whenComplete_mustExposeAllProperties() throws IOException { - ExtractionResponse response = loadResponse( - "products/extraction/financial_document/complete.json" - ); + var response = loadResponse("products/extraction/financial_document/complete.json"); ExtractionInference inference = response.getInference(); assertNotNull(inference); assertEquals("12345678-1234-1234-1234-123456789abc", inference.getId()); @@ -130,7 +126,7 @@ void asyncPredict_whenComplete_mustExposeAllProperties() throws IOException { assertEquals("image/jpeg", file.getMimeType()); assertNull(file.getAlias()); - InferenceFields fields = inference.getResult().getFields(); + var fields = inference.getResult().getFields(); assertEquals(21, fields.size()); SimpleField date = fields.get("date").getSimpleField(); @@ -188,7 +184,7 @@ void deepNestedFields_mustExposeCorrectTypes() throws IOException { ExtractionInference inf = resp.getInference(); assertNotNull(inf); - InferenceFields root = inf.getResult().getFields(); + var root = inf.getResult().getFields(); assertNotNull(root.get("field_simple").getSimpleField()); assertNotNull(root.get("field_object").getObjectField()); @@ -250,20 +246,20 @@ private void testSimpleFieldString(SimpleField field) { @Test @DisplayName("simple fields must be recognised") void standardFieldTypes_mustExposeSimpleFieldValues() throws IOException { - ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); + var response = loadResponse("products/extraction/standard_field_types.json"); ExtractionInference inference = response.getInference(); assertNotNull(inference); - InferenceFields fields = inference.getResult().getFields(); + var fields = inference.getResult().getFields(); assertNotNull(fields.get("field_simple_string").getSimpleField()); - SimpleField fieldSimpleString = fields.getSimpleField("field_simple_string"); + var fieldSimpleString = fields.getSimpleField("field_simple_string"); testSimpleFieldString(fieldSimpleString); assertEquals(FieldConfidence.Certain, fieldSimpleString.getConfidence()); assertEquals(1, fieldSimpleString.getLocations().size()); - SimpleField fieldSimpleFloat = fields.get("field_simple_float").getSimpleField(); + var fieldSimpleFloat = fields.get("field_simple_float").getSimpleField(); assertNotNull(fieldSimpleFloat); assertInstanceOf(Double.class, fieldSimpleFloat.getValue()); assertEquals(fieldSimpleFloat.getValue(), fieldSimpleFloat.getDoubleValue()); @@ -271,14 +267,14 @@ void standardFieldTypes_mustExposeSimpleFieldValues() throws IOException { assertThrows(ClassCastException.class, fieldSimpleFloat::getBooleanValue); assertEquals(FieldConfidence.High, fieldSimpleFloat.getConfidence()); - SimpleField fieldSimpleInt = fields.get("field_simple_int").getSimpleField(); + var fieldSimpleInt = fields.get("field_simple_int").getSimpleField(); assertNotNull(fieldSimpleInt); assertInstanceOf(Double.class, fieldSimpleInt.getValue()); assertEquals(fieldSimpleInt.getValue(), fieldSimpleInt.getDoubleValue()); assertEquals(FieldConfidence.Medium, fieldSimpleInt.getConfidence()); assertThrows(ClassCastException.class, fieldSimpleInt::getStringValue); - SimpleField fieldSimpleZero = fields.get("field_simple_zero").getSimpleField(); + var fieldSimpleZero = fields.get("field_simple_zero").getSimpleField(); assertNotNull(fieldSimpleZero); assertEquals(FieldConfidence.Low, fieldSimpleZero.getConfidence()); assertInstanceOf(Double.class, fieldSimpleZero.getValue()); @@ -287,7 +283,7 @@ void standardFieldTypes_mustExposeSimpleFieldValues() throws IOException { assertThrows(ClassCastException.class, fieldSimpleZero::getStringValue); assertThrows(ClassCastException.class, fieldSimpleZero::getBooleanValue); - SimpleField fieldSimpleBool = fields.get("field_simple_bool").getSimpleField(); + var fieldSimpleBool = fields.get("field_simple_bool").getSimpleField(); assertNotNull(fieldSimpleBool); assertInstanceOf(Boolean.class, fieldSimpleBool.getValue()); assertEquals(fieldSimpleBool.getValue(), fieldSimpleBool.getBooleanValue()); @@ -295,7 +291,7 @@ void standardFieldTypes_mustExposeSimpleFieldValues() throws IOException { assertThrows(ClassCastException.class, fieldSimpleBool::getDoubleValue); assertThrows(ClassCastException.class, fieldSimpleBool::getBigDecimalValue); - SimpleField fieldSimpleNull = fields.get("field_simple_null").getSimpleField(); + var fieldSimpleNull = fields.get("field_simple_null").getSimpleField(); assertNotNull(fieldSimpleNull); assertNull(fieldSimpleNull.getValue()); assertNull(fieldSimpleNull.getStringValue()); @@ -307,13 +303,13 @@ void standardFieldTypes_mustExposeSimpleFieldValues() throws IOException { @Test @DisplayName("simple list fields must be recognised") void standardFieldTypes_mustExposeSimpleListFieldValues() throws IOException { - ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); - ExtractionInference inference = response.getInference(); + var response = loadResponse("products/extraction/standard_field_types.json"); + var inference = response.getInference(); assertNotNull(inference); - InferenceFields fields = inference.getResult().getFields(); + var fields = inference.getResult().getFields(); - ListField listField = fields.get("field_simple_list").getListField(); + var listField = fields.get("field_simple_list").getListField(); assertNotNull(listField); // Low level (dynamic) access @@ -350,11 +346,11 @@ private void testObjectSubFieldSimpleString(String fieldName, SimpleField subFie @Test @DisplayName("object list fields must be recognised") void standardFieldTypes_mustExposeObjectListFieldValues() throws IOException { - ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); - ExtractionInference inference = response.getInference(); + var response = loadResponse("products/extraction/standard_field_types.json"); + var inference = response.getInference(); assertNotNull(inference); - InferenceFields fields = inference.getResult().getFields(); + var fields = inference.getResult().getFields(); ListField listField = fields.get("field_object_list").getListField(); assertNotNull(listField); @@ -400,11 +396,11 @@ void standardFieldTypes_mustExposeObjectListFieldValues() throws IOException { @Test @DisplayName("simple / object / list variants must be recognised") void standardFieldTypes_mustExposeObjectFieldValues() throws IOException { - ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); - ExtractionInference inference = response.getInference(); + var response = loadResponse("products/extraction/standard_field_types.json"); + var inference = response.getInference(); assertNotNull(inference); - InferenceFields fields = inference.getResult().getFields(); + var fields = inference.getResult().getFields(); ObjectField fieldObject = fields.get("field_object").getObjectField(); assertNotNull(fieldObject); @@ -435,10 +431,10 @@ void standardFieldTypes_mustExposeObjectFieldValues() throws IOException { @Test @DisplayName("allow getting fields using generics") void standardFieldTypes_getWithGenerics() throws IOException { - ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); - ExtractionInference inference = response.getInference(); + var response = loadResponse("products/extraction/standard_field_types.json"); + var inference = response.getInference(); assertNotNull(inference); - InferenceFields fields = inference.getResult().getFields(); + var fields = inference.getResult().getFields(); assertEquals( fields.get("field_simple_bool").getSimpleField(), @@ -471,11 +467,11 @@ void standardFieldTypes_getWithGenerics() throws IOException { @Test @DisplayName("confidence and locations must be usable") void standardFieldTypes_confidenceAndLocations() throws IOException { - ExtractionResponse response = loadResponse("products/extraction/standard_field_types.json"); - ExtractionInference inference = response.getInference(); + var response = loadResponse("products/extraction/standard_field_types.json"); + var inference = response.getInference(); assertNotNull(inference); - InferenceFields fields = inference.getResult().getFields(); + var fields = inference.getResult().getFields(); SimpleField fieldSimpleString = fields.get("field_simple_string").getField(SimpleField.class); FieldConfidence confidence = fieldSimpleString.getConfidence(); @@ -511,8 +507,8 @@ class RawTextTest { @Test @DisplayName("raw texts option must be parsed and exposed") void rawTexts_mustBeAccessible() throws IOException { - ExtractionResponse response = loadResponse("products/extraction/raw_texts.json"); - ExtractionInference inference = response.getInference(); + var response = loadResponse("products/extraction/raw_texts.json"); + var inference = response.getInference(); assertNotNull(inference); InferenceActiveOptions activeOptions = inference.getActiveOptions(); @@ -546,8 +542,8 @@ class RagMetadataTest { @Test @DisplayName("RAG metadata when matched") void rag_mustBeFilled_whenMatched() throws IOException { - ExtractionResponse response = loadResponse("products/extraction/rag_matched.json"); - ExtractionInference inference = response.getInference(); + var response = loadResponse("products/extraction/rag_matched.json"); + var inference = response.getInference(); assertNotNull(inference); RagMetadata rag = inference.getResult().getRag(); @@ -558,8 +554,8 @@ void rag_mustBeFilled_whenMatched() throws IOException { @Test @DisplayName("RAG metadata when not matched") void rag_mustBeNull_whenNotMatched() throws IOException { - ExtractionResponse response = loadResponse("products/extraction/rag_not_matched.json"); - ExtractionInference inference = response.getInference(); + var response = loadResponse("products/extraction/rag_not_matched.json"); + var inference = response.getInference(); assertNotNull(inference); RagMetadata rag = inference.getResult().getRag(); @@ -574,10 +570,9 @@ class RstDisplay { @Test @DisplayName("rst display must be parsed and exposed") void rstDisplay_mustBeAccessible() throws IOException { - ExtractionResponse resp = loadResponse("products/extraction/standard_field_types.json"); - String rstRef = readFileAsString( - getV2ResourcePath("products/extraction/standard_field_types.rst") - ); + var resp = loadResponse("products/extraction/standard_field_types.json"); + String rstRef = Files + .readString(getV2ResourcePath("products/extraction/standard_field_types.rst")); ExtractionInference inference = resp.getInference(); assertNotNull(inference); assertEquals(rstRef, resp.getInference().toString()); @@ -590,7 +585,7 @@ class TextContextTest { @Test @DisplayName("should be present and true when enabled") void textContext_mustBePresentAndTrue() throws IOException { - ExtractionResponse resp = loadResponse("products/extraction/text_context_enabled.json"); + var resp = loadResponse("products/extraction/text_context_enabled.json"); ExtractionInference inference = resp.getInference(); assertNotNull(inference); assertTrue(inference.getActiveOptions().getTextContext()); @@ -603,10 +598,10 @@ class DataSchemaTest { @Test @DisplayName("should be present and true when enabled") void textContext_mustBePresentAndTrue() throws IOException { - ExtractionResponse resp = loadResponse("products/extraction/data_schema_replace.json"); + var resp = loadResponse("products/extraction/data_schema_replace.json"); ExtractionInference inference = resp.getInference(); assertNotNull(inference); - InferenceFields fields = inference.getResult().getFields(); + var fields = inference.getResult().getFields(); assertEquals("a test value", fields.get("test_replace").getSimpleField().getStringValue()); assertTrue(inference.getActiveOptions().getDataSchema().getReplace()); diff --git a/src/test/java/com/mindee/v2/parsing/JobTest.java b/src/test/java/com/mindee/v2/parsing/JobTest.java index e4d2f3c8b..87f27fd26 100644 --- a/src/test/java/com/mindee/v2/parsing/JobTest.java +++ b/src/test/java/com/mindee/v2/parsing/JobTest.java @@ -14,7 +14,7 @@ @DisplayName("MindeeV2 - Job Tests") public class JobTest { private JobResponse loadJob(String filePath) throws IOException { - LocalResponse localResponse = new LocalResponse(getV2ResourcePath(filePath)); + var localResponse = new LocalResponse(getV2ResourcePath(filePath)); return localResponse.deserializeResponse(JobResponse.class); } @@ -24,8 +24,8 @@ class ProcessingTest { @Test @DisplayName("properties must be valid") void whenProcessing_mustHaveValidProperties() throws IOException { - JobResponse response = loadJob("job/ok_processing.json"); - Job job = response.getJob(); + var response = loadJob("job/ok_processing.json"); + var job = response.getJob(); assertNotNull(job); assertEquals("Processing", job.getStatus()); assertNotNull(job.getCreatedAt()); @@ -41,8 +41,8 @@ class ProcessedTest { @Test @DisplayName("properties must be valid") void whenProcessing_mustHaveValidProperties() throws IOException { - JobResponse response = loadJob("job/ok_processed_webhooks_ok.json"); - Job job = response.getJob(); + var response = loadJob("job/ok_processed_webhooks_ok.json"); + var job = response.getJob(); assertNotNull(job); assertEquals("Processed", job.getStatus()); assertNotNull(job.getCreatedAt()); @@ -58,8 +58,8 @@ class FailTest { @Test @DisplayName("HTTP 422 properties must be valid") void when422_mustHaveValidProperties() throws IOException { - JobResponse response = loadJob("job/fail_422.json"); - Job job = response.getJob(); + var response = loadJob("job/fail_422.json"); + var job = response.getJob(); assertNotNull(job); assertNotNull(job.getCreatedAt()); assertNotNull(job.getCompletedAt()); diff --git a/src/test/java/com/mindee/v2/product/ClassificationTest.java b/src/test/java/com/mindee/v2/product/ClassificationTest.java index d73f029bb..d7701c82c 100644 --- a/src/test/java/com/mindee/v2/product/ClassificationTest.java +++ b/src/test/java/com/mindee/v2/product/ClassificationTest.java @@ -14,7 +14,7 @@ @DisplayName("MindeeV2 - Classification Model Tests") public class ClassificationTest { private ClassificationResponse loadResponse(String filePath) throws IOException { - LocalResponse localResponse = new LocalResponse(getV2ResourcePath(filePath)); + var localResponse = new LocalResponse(getV2ResourcePath(filePath)); return localResponse.deserializeResponse(ClassificationResponse.class); } diff --git a/src/test/java/com/mindee/v2/product/CropIT.java b/src/test/java/com/mindee/v2/product/CropIT.java index 9aa3abff3..336dabe22 100644 --- a/src/test/java/com/mindee/v2/product/CropIT.java +++ b/src/test/java/com/mindee/v2/product/CropIT.java @@ -6,10 +6,7 @@ import com.mindee.AsyncPollingOptions; import com.mindee.input.LocalInputSource; import com.mindee.v2.MindeeClient; -import com.mindee.v2.parsing.inference.InferenceFile; -import com.mindee.v2.product.crop.CropInference; import com.mindee.v2.product.crop.CropResponse; -import com.mindee.v2.product.crop.CropResult; import com.mindee.v2.product.crop.params.CropParameters; import java.io.IOException; import org.junit.jupiter.api.BeforeAll; @@ -28,7 +25,7 @@ class CropIT { @BeforeAll void setUp() { - String apiKey = System.getenv("MINDEE_V2_API_KEY"); + var apiKey = System.getenv("MINDEE_V2_API_KEY"); modelId = System.getenv("MINDEE_V2_SE_TESTS_CROP_MODEL_ID"); mindeeClient = new MindeeClient(apiKey); } @@ -36,9 +33,7 @@ void setUp() { @Test @DisplayName("Empty, multi-page PDF – enqueue & parse must succeed") void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedException { - LocalInputSource source = new LocalInputSource( - getResourcePath("file_types/pdf/multipage_cut-2.pdf") - ); + var source = new LocalInputSource(getResourcePath("file_types/pdf/multipage_cut-2.pdf")); CropParameters params = CropParameters .builder(modelId) .alias("java_integration-test_crop_multipage") @@ -49,10 +44,11 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep CropResponse response = mindeeClient.enqueueAndGetResult(CropResponse.class, source, params); assertNotNull(response); - CropInference inference = response.getInference(); + + var inference = response.getInference(); assertNotNull(inference); - InferenceFile file = inference.getFile(); + var file = inference.getFile(); assertNotNull(file); assertEquals("multipage_cut-2.pdf", file.getName()); assertEquals(2, file.getPageCount()); @@ -60,7 +56,7 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep assertNotNull(inference.getModel()); assertEquals(modelId, inference.getModel().getId()); - CropResult result = inference.getResult(); + var result = inference.getResult(); assertNotNull(result); assertEquals(1, result.getCrops().size()); assertEquals("other", result.getCrops().get(0).getObjectType()); diff --git a/src/test/java/com/mindee/v2/product/CropTest.java b/src/test/java/com/mindee/v2/product/CropTest.java index f0df46732..b171a1653 100644 --- a/src/test/java/com/mindee/v2/product/CropTest.java +++ b/src/test/java/com/mindee/v2/product/CropTest.java @@ -6,10 +6,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import com.mindee.input.LocalResponse; -import com.mindee.v2.product.crop.CropItem; import com.mindee.v2.product.crop.CropResponse; import java.io.IOException; -import java.util.ArrayList; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -17,7 +15,7 @@ @DisplayName("MindeeV2 - Crop Model Tests") public class CropTest { private CropResponse loadResponse(String filePath) throws IOException { - LocalResponse localResponse = new LocalResponse(getV2ResourcePath(filePath)); + var localResponse = new LocalResponse(getV2ResourcePath(filePath)); return localResponse.deserializeResponse(CropResponse.class); } @@ -27,13 +25,13 @@ class SinglePredictionTest { @Test @DisplayName("all properties must be valid") void mustHaveValidProperties() throws IOException { - CropResponse response = loadResponse("products/crop/crop_single.json"); + var response = loadResponse("products/crop/crop_single.json"); assertNotNull(response.getInference()); - ArrayList crops = response.getInference().getResult().getCrops(); + var crops = response.getInference().getResult().getCrops(); assertEquals(1, crops.size()); - CropItem crop1 = crops.get(0); + var crop1 = crops.get(0); assertEquals("invoice", crop1.getObjectType()); assertNotNull(crop1.getLocation().getPolygon()); assertEquals(0, crop1.getLocation().getPage()); @@ -42,7 +40,7 @@ void mustHaveValidProperties() throws IOException { @Test @DisplayName("RST output must be valid") void mustHaveValidDisplay() throws IOException { - CropResponse response = loadResponse("products/crop/crop_single.json"); + var response = loadResponse("products/crop/crop_single.json"); assertStringEqualsFile( response.getInference().toString(), getV2ResourcePath("products/crop/crop_single.rst") @@ -56,18 +54,18 @@ class MultiPredictionTest { @Test @DisplayName("all properties must be valid") void mustHaveValidProperties() throws IOException { - CropResponse response = loadResponse("products/crop/crop_multiple.json"); + var response = loadResponse("products/crop/crop_multiple.json"); assertNotNull(response.getInference()); - ArrayList crops = response.getInference().getResult().getCrops(); + var crops = response.getInference().getResult().getCrops(); assertEquals(2, crops.size()); - CropItem crop1 = crops.get(0); + var crop1 = crops.get(0); assertEquals("invoice", crop1.getObjectType()); assertNotNull(crop1.getLocation().getPolygon()); assertEquals(0, crop1.getLocation().getPage()); - CropItem crop2 = crops.get(1); + var crop2 = crops.get(1); assertEquals("receipt", crop2.getObjectType()); assertNotNull(crop2.getLocation().getPolygon()); assertEquals(0, crop2.getLocation().getPage()); @@ -76,7 +74,7 @@ void mustHaveValidProperties() throws IOException { @Test @DisplayName("RST output must be valid") void mustHaveValidDisplay() throws IOException { - CropResponse response = loadResponse("products/crop/crop_multiple.json"); + var response = loadResponse("products/crop/crop_multiple.json"); assertStringEqualsFile( response.getInference().toString(), getV2ResourcePath("products/crop/crop_multiple.rst") diff --git a/src/test/java/com/mindee/v2/product/OcrTest.java b/src/test/java/com/mindee/v2/product/OcrTest.java index c39268be0..ef734eec0 100644 --- a/src/test/java/com/mindee/v2/product/OcrTest.java +++ b/src/test/java/com/mindee/v2/product/OcrTest.java @@ -5,10 +5,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import com.mindee.input.LocalResponse; -import com.mindee.v2.product.ocr.OcrPage; import com.mindee.v2.product.ocr.OcrResponse; import java.io.IOException; -import java.util.ArrayList; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -16,7 +14,7 @@ @DisplayName("MindeeV2 - OCR Model Tests") public class OcrTest { private OcrResponse loadResponse(String filePath) throws IOException { - LocalResponse localResponse = new LocalResponse(getV2ResourcePath(filePath)); + var localResponse = new LocalResponse(getV2ResourcePath(filePath)); return localResponse.deserializeResponse(OcrResponse.class); } @@ -26,10 +24,10 @@ class SinglePredictionTest { @Test @DisplayName("all properties must be valid") void mustHaveValidProperties() throws IOException { - OcrResponse response = loadResponse("products/ocr/ocr_single.json"); + var response = loadResponse("products/ocr/ocr_single.json"); assertNotNull(response.getInference()); - ArrayList pages = response.getInference().getResult().getPages(); + var pages = response.getInference().getResult().getPages(); assertEquals(1, pages.size()); assertEquals(305, pages.get(0).getWords().size()); assertEquals("Shipper:", pages.get(0).getWords().get(0).getContent()); @@ -42,18 +40,18 @@ class MultiPredictionTest { @Test @DisplayName("all properties must be valid") void mustHaveValidProperties() throws IOException { - OcrResponse response = loadResponse("products/ocr/ocr_multiple.json"); + var response = loadResponse("products/ocr/ocr_multiple.json"); assertNotNull(response.getInference()); - ArrayList pages = response.getInference().getResult().getPages(); + var pages = response.getInference().getResult().getPages(); assertEquals(3, pages.size()); - OcrPage page1 = pages.get(0); + var page1 = pages.get(0); assertNotNull(page1.getContent()); assertEquals(295, page1.getWords().size()); assertEquals("FICTIOCORP", page1.getWords().get(0).getContent()); - OcrPage page2 = pages.get(1); + var page2 = pages.get(1); assertNotNull(page2.getContent()); assertEquals(450, page2.getWords().size()); assertEquals("KEOLIO", page2.getWords().get(0).getContent()); diff --git a/src/test/java/com/mindee/v2/product/SplitIT.java b/src/test/java/com/mindee/v2/product/SplitIT.java index 8c536b528..6419c0bac 100644 --- a/src/test/java/com/mindee/v2/product/SplitIT.java +++ b/src/test/java/com/mindee/v2/product/SplitIT.java @@ -8,10 +8,7 @@ import com.mindee.AsyncPollingOptions; import com.mindee.input.LocalInputSource; import com.mindee.v2.MindeeClient; -import com.mindee.v2.parsing.inference.InferenceFile; -import com.mindee.v2.product.split.SplitInference; import com.mindee.v2.product.split.SplitResponse; -import com.mindee.v2.product.split.SplitResult; import com.mindee.v2.product.split.params.SplitParameters; import java.io.IOException; import org.junit.jupiter.api.BeforeAll; @@ -30,7 +27,7 @@ class SplitIT { @BeforeAll void setUp() { - String apiKey = System.getenv("MINDEE_V2_API_KEY"); + var apiKey = System.getenv("MINDEE_V2_API_KEY"); modelId = System.getenv("MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID"); mindeeClient = new MindeeClient(apiKey); } @@ -38,10 +35,8 @@ void setUp() { @Test @DisplayName("Empty, multi-page PDF – enqueue & parse must succeed") void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedException { - LocalInputSource source = new LocalInputSource( - getResourcePath("file_types/pdf/multipage_cut-2.pdf") - ); - SplitParameters params = SplitParameters + var source = new LocalInputSource(getResourcePath("file_types/pdf/multipage_cut-2.pdf")); + var params = SplitParameters .builder(modelId) .alias("java_integration-test_split_multipage") .pollingOptions( @@ -49,12 +44,13 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep ) .build(); - SplitResponse response = mindeeClient.enqueueAndGetResult(SplitResponse.class, source, params); + var response = mindeeClient.enqueueAndGetResult(SplitResponse.class, source, params); assertNotNull(response); - SplitInference inference = response.getInference(); + + var inference = response.getInference(); assertNotNull(inference); - InferenceFile file = inference.getFile(); + var file = inference.getFile(); assertNotNull(file); assertEquals("multipage_cut-2.pdf", file.getName()); assertEquals(2, file.getPageCount()); @@ -62,7 +58,7 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep assertNotNull(inference.getModel()); assertEquals(modelId, inference.getModel().getId()); - SplitResult result = inference.getResult(); + var result = inference.getResult(); assertNotNull(result); assertTrue(result.getSplits().isEmpty()); } diff --git a/src/test/java/com/mindee/v2/product/SplitTest.java b/src/test/java/com/mindee/v2/product/SplitTest.java index 08a21bef8..d4ff870d1 100644 --- a/src/test/java/com/mindee/v2/product/SplitTest.java +++ b/src/test/java/com/mindee/v2/product/SplitTest.java @@ -5,10 +5,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import com.mindee.input.LocalResponse; -import com.mindee.v2.product.split.SplitRange; import com.mindee.v2.product.split.SplitResponse; import java.io.IOException; -import java.util.ArrayList; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -16,7 +14,7 @@ @DisplayName("MindeeV2 - Split Model Tests") public class SplitTest { private SplitResponse loadResponse(String filePath) throws IOException { - LocalResponse localResponse = new LocalResponse(getV2ResourcePath(filePath)); + var localResponse = new LocalResponse(getV2ResourcePath(filePath)); return localResponse.deserializeResponse(SplitResponse.class); } @@ -26,10 +24,10 @@ class SinglePredictionTest { @Test @DisplayName("all properties must be valid") void mustHaveValidProperties() throws IOException { - SplitResponse response = loadResponse("products/split/split_single.json"); + var response = loadResponse("products/split/split_single.json"); assertNotNull(response.getInference()); - ArrayList splits = response.getInference().getResult().getSplits(); + var splits = response.getInference().getResult().getSplits(); assertEquals(1, splits.size()); assertEquals("receipt", splits.get(0).getDocumentType()); assertEquals(0, splits.get(0).getPageRange().get(0)); @@ -42,21 +40,21 @@ class MultiPredictionTest { @Test @DisplayName("all properties must be valid") void mustHaveValidProperties() throws IOException { - SplitResponse response = loadResponse("products/split/split_multiple.json"); + var response = loadResponse("products/split/split_multiple.json"); assertNotNull(response.getInference()); - ArrayList splits = response.getInference().getResult().getSplits(); + var splits = response.getInference().getResult().getSplits(); assertEquals(3, splits.size()); - SplitRange split1 = splits.get(0); + var split1 = splits.get(0); assertEquals("passport", split1.getDocumentType()); assertEquals(0, split1.getPageRange().get(0)); - SplitRange split2 = splits.get(1); + var split2 = splits.get(1); assertEquals("invoice", split2.getDocumentType()); assertEquals(1, split2.getPageRange().get(0)); - SplitRange split3 = splits.get(2); + var split3 = splits.get(2); assertEquals("receipt", split3.getDocumentType()); assertEquals(4, split3.getPageRange().get(0)); } From ec21193ced2c23c5879381244e4c637d55a1241f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Tue, 7 Apr 2026 12:38:29 +0200 Subject: [PATCH 5/9] move http v1 tests --- .../java/com/mindee/{ => v1}/http/MindeeHttpApiV1Test.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) rename src/test/java/com/mindee/{ => v1}/http/MindeeHttpApiV1Test.java (98%) diff --git a/src/test/java/com/mindee/http/MindeeHttpApiV1Test.java b/src/test/java/com/mindee/v1/http/MindeeHttpApiV1Test.java similarity index 98% rename from src/test/java/com/mindee/http/MindeeHttpApiV1Test.java rename to src/test/java/com/mindee/v1/http/MindeeHttpApiV1Test.java index 036545bcd..1898864f9 100644 --- a/src/test/java/com/mindee/http/MindeeHttpApiV1Test.java +++ b/src/test/java/com/mindee/v1/http/MindeeHttpApiV1Test.java @@ -1,4 +1,4 @@ -package com.mindee.http; +package com.mindee.v1.http; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.containing; @@ -15,10 +15,6 @@ import com.github.tomakehurst.wiremock.junit.WireMockRule; import com.mindee.v1.MindeeSettings; import com.mindee.v1.clientOptions.PredictOptions; -import com.mindee.v1.http.Endpoint; -import com.mindee.v1.http.MindeeHttpApiV1; -import com.mindee.v1.http.MindeeHttpExceptionV1; -import com.mindee.v1.http.RequestParameters; import com.mindee.v1.parsing.common.AsyncPredictResponse; import com.mindee.v1.parsing.common.Document; import com.mindee.v1.parsing.common.PredictResponse; From e76796528a112d37faee5c090577bc8e6aa8aac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Tue, 7 Apr 2026 17:24:14 +0200 Subject: [PATCH 6/9] :recycle: :boom: LocalResponse class should be version-specific (#311) --- .../BaseLocalResponse.java} | 41 ++----- src/main/java/com/mindee/v1/MindeeClient.java | 27 ----- .../com/mindee/v1/parsing/LocalResponse.java | 85 +++++++++++++++ .../com/mindee/v2/parsing/LocalResponse.java | 52 +++++++++ .../com/mindee/input/LocalResponseV1Test.java | 61 ----------- .../java/com/mindee/v1/MindeeClientTest.java | 31 ------ .../mindee/v1/parsing/LocalResponseTest.java | 101 ++++++++++++++++++ .../java/com/mindee/v2/MindeeClientTest.java | 43 +------- .../input/LocalResponseTest.java} | 18 ++-- .../java/com/mindee/v2/parsing/JobTest.java | 1 - .../mindee/v2/parsing/LocalResponseTest.java | 50 +++++++++ .../mindee/v2/product/ClassificationTest.java | 2 +- .../java/com/mindee/v2/product/CropTest.java | 2 +- .../{parsing => product}/ExtractionTest.java | 4 +- .../java/com/mindee/v2/product/OcrTest.java | 2 +- .../java/com/mindee/v2/product/SplitTest.java | 2 +- 16 files changed, 315 insertions(+), 207 deletions(-) rename src/main/java/com/mindee/{input/LocalResponse.java => parsing/BaseLocalResponse.java} (66%) create mode 100644 src/main/java/com/mindee/v1/parsing/LocalResponse.java create mode 100644 src/main/java/com/mindee/v2/parsing/LocalResponse.java delete mode 100644 src/test/java/com/mindee/input/LocalResponseV1Test.java create mode 100644 src/test/java/com/mindee/v1/parsing/LocalResponseTest.java rename src/test/java/com/mindee/{input/LocalResponseV2Test.java => v2/input/LocalResponseTest.java} (75%) create mode 100644 src/test/java/com/mindee/v2/parsing/LocalResponseTest.java rename src/test/java/com/mindee/v2/{parsing => product}/ExtractionTest.java (99%) diff --git a/src/main/java/com/mindee/input/LocalResponse.java b/src/main/java/com/mindee/parsing/BaseLocalResponse.java similarity index 66% rename from src/main/java/com/mindee/input/LocalResponse.java rename to src/main/java/com/mindee/parsing/BaseLocalResponse.java index 3eabd1423..3284e9984 100644 --- a/src/main/java/com/mindee/input/LocalResponse.java +++ b/src/main/java/com/mindee/parsing/BaseLocalResponse.java @@ -1,8 +1,5 @@ -package com.mindee.input; +package com.mindee.parsing; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.MindeeException; -import com.mindee.v2.parsing.CommonResponse; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -24,16 +21,15 @@ * A Mindee response saved locally. */ @Getter -public class LocalResponse { - private final byte[] file; - private static final ObjectMapper mapper = new ObjectMapper(); +public abstract class BaseLocalResponse { + protected final byte[] file; /** * Load from an {@link InputStream}. * * @param input will be decoded as UTF-8. */ - public LocalResponse(InputStream input) { + public BaseLocalResponse(InputStream input) { this.file = this .getBytes(new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines()); } @@ -43,7 +39,10 @@ public LocalResponse(InputStream input) { * * @param input will be decoded as UTF-8. */ - public LocalResponse(String input) { + public BaseLocalResponse(String input) { + if (input == null || input.isEmpty()) { + throw new IllegalArgumentException("Input string cannot be empty or null."); + } this.file = input.getBytes(StandardCharsets.UTF_8); } @@ -52,7 +51,7 @@ public LocalResponse(String input) { * * @param input will be decoded as UTF-8. */ - public LocalResponse(File input) throws IOException { + public BaseLocalResponse(File input) throws IOException { this.file = this.getBytes(Files.lines(input.toPath(), StandardCharsets.UTF_8)); } @@ -61,7 +60,7 @@ public LocalResponse(File input) throws IOException { * * @param input will be decoded as UTF-8. */ - public LocalResponse(Path input) throws IOException { + public BaseLocalResponse(Path input) throws IOException { this.file = this.getBytes(Files.lines(input, StandardCharsets.UTF_8)); } @@ -106,24 +105,4 @@ public String getHmacSignature(String secretKey) { public boolean isValidHmacSignature(String secretKey, String signature) { return signature.equals(getHmacSignature(secretKey)); } - - /** - * Deserialize this local JSON payload into a specific {@link CommonResponse} - * subtype: {@code InferenceResponse}, {@code JobResponse}. - * - * @param responseClass the concrete class to instantiate - * @param generic {@link CommonResponse} - * @return Either a {@code InferenceResponse} or {@code JobResponse} instance. - * @throws MindeeException if the payload cannot be deserialized into the requested type - */ - public T deserializeResponse(Class responseClass) { - ObjectMapper mapper = new ObjectMapper(); - try { - T response = mapper.readValue(this.file, responseClass); - response.setRawResponse(new String(this.file, StandardCharsets.UTF_8)); - return response; - } catch (Exception ex) { - throw new MindeeException("Invalid class specified for deserialization.", ex); - } - } } diff --git a/src/main/java/com/mindee/v1/MindeeClient.java b/src/main/java/com/mindee/v1/MindeeClient.java index 7c401c04a..f9c3ea5b3 100644 --- a/src/main/java/com/mindee/v1/MindeeClient.java +++ b/src/main/java/com/mindee/v1/MindeeClient.java @@ -1,12 +1,9 @@ package com.mindee.v1; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; import com.mindee.AsyncPollingOptions; import com.mindee.MindeeException; import com.mindee.input.InputSourceUtils; import com.mindee.input.LocalInputSource; -import com.mindee.input.LocalResponse; import com.mindee.input.PageOptions; import com.mindee.pdf.PdfBoxApi; import com.mindee.pdf.PdfOperation; @@ -1071,28 +1068,4 @@ public AsyncPredictResponse parseQueued( ) { return this.mindeeApi.documentQueueGet(type, endpoint, jobId); } - - /** - * Load a local prediction. - * Typically used when wanting to load from a webhook callback. - * However, any kind of Mindee response may be loaded. - * - * @param Type of inference. - * @param type Type of inference. - * @param localResponse A loaded local response. - * @return an instance of {@link AsyncPredictResponse}. - * @throws IOException Throws if the file can't be accessed. - */ - public AsyncPredictResponse loadPrediction( - Class type, - LocalResponse localResponse - ) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - JavaType parametricType = objectMapper - .getTypeFactory() - .constructParametricType(AsyncPredictResponse.class, type); - return objectMapper.readValue(localResponse.getFile(), parametricType); - } - } diff --git a/src/main/java/com/mindee/v1/parsing/LocalResponse.java b/src/main/java/com/mindee/v1/parsing/LocalResponse.java new file mode 100644 index 000000000..b9244d014 --- /dev/null +++ b/src/main/java/com/mindee/v1/parsing/LocalResponse.java @@ -0,0 +1,85 @@ +package com.mindee.v1.parsing; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.mindee.MindeeException; +import com.mindee.parsing.BaseLocalResponse; +import com.mindee.v1.parsing.common.AsyncPredictResponse; +import com.mindee.v1.parsing.common.Inference; +import com.mindee.v1.parsing.common.PredictResponse; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; + +/** + * A Mindee response saved locally. + */ +public class LocalResponse extends BaseLocalResponse { + + public LocalResponse(InputStream input) { + super(input); + } + + public LocalResponse(String input) { + super(input); + } + + public LocalResponse(File input) throws IOException { + super(input); + } + + public LocalResponse(Path input) throws IOException { + super(input); + } + + private

R deserialize( + Class responseClass, + Class

productClass + ) throws IOException { + var mapper = new ObjectMapper().findAndRegisterModules(); + var type = mapper.getTypeFactory().constructParametricType(responseClass, productClass); + try { + return mapper.readValue(this.file, type); + } catch (Exception e) { + if (e instanceof JacksonException) { + throw new MindeeException("Invalid JSON payload.", e); + } + throw e; + } + } + + /** + * Deserialize this local JSON payload into a specific {@link AsyncPredictResponse}. + * subtype: {@code InferenceResponse}, {@code JobResponse}. + * + * @param productClass the concrete class to instantiate + * @param generic {@link Inference} + * @return A {@link AsyncPredictResponse} instance. + * @throws MindeeException if the payload cannot be deserialized into the requested type + */ + public AsyncPredictResponse deserializeAsyncResponse( + Class productClass + ) throws IOException { + AsyncPredictResponse response = deserialize(AsyncPredictResponse.class, productClass); + response.setRawResponse(new String(this.file, StandardCharsets.UTF_8)); + return response; + } + + /** + * Deserialize this local JSON payload into a specific {@link PredictResponse}. + * + * @param productClass the concrete class to instantiate + * @param generic {@link Inference} + * @return A {@link PredictResponse} instance. + * @throws MindeeException if the payload cannot be deserialized into the requested type + */ + public PredictResponse deserializeSyncResponse( + Class productClass + ) throws IOException { + PredictResponse response = deserialize(PredictResponse.class, productClass); + response.setRawResponse(new String(this.file, StandardCharsets.UTF_8)); + return response; + } +} diff --git a/src/main/java/com/mindee/v2/parsing/LocalResponse.java b/src/main/java/com/mindee/v2/parsing/LocalResponse.java new file mode 100644 index 000000000..33ec16410 --- /dev/null +++ b/src/main/java/com/mindee/v2/parsing/LocalResponse.java @@ -0,0 +1,52 @@ +package com.mindee.v2.parsing; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.mindee.MindeeException; +import com.mindee.parsing.BaseLocalResponse; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; + +/** + * A Mindee response saved locally. + */ +public class LocalResponse extends BaseLocalResponse { + + public LocalResponse(InputStream input) { + super(input); + } + + public LocalResponse(String input) { + super(input); + } + + public LocalResponse(File input) throws IOException { + super(input); + } + + public LocalResponse(Path input) throws IOException { + super(input); + } + + /** + * Deserialize this local JSON payload into a specific {@link CommonResponse} + * subtype: {@code InferenceResponse}, {@code JobResponse}. + * + * @param responseClass the concrete class to instantiate + * @param generic {@link CommonResponse} + * @return Either a {@code InferenceResponse} or {@code JobResponse} instance. + * @throws MindeeException if the payload cannot be deserialized into the requested type + */ + public T deserializeResponse(Class responseClass) { + var mapper = new ObjectMapper().findAndRegisterModules(); + try { + var response = mapper.readValue(this.file, responseClass); + response.setRawResponse(new String(this.file, StandardCharsets.UTF_8)); + return response; + } catch (Exception e) { + throw new MindeeException("Invalid JSON payload.", e); + } + } +} diff --git a/src/test/java/com/mindee/input/LocalResponseV1Test.java b/src/test/java/com/mindee/input/LocalResponseV1Test.java deleted file mode 100644 index cef89b839..000000000 --- a/src/test/java/com/mindee/input/LocalResponseV1Test.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.mindee.input; - -import static com.mindee.TestingUtilities.getV1ResourcePath; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -public class LocalResponseV1Test { - /** - * Fake secret key. - */ - String secretKey = "ogNjY44MhvKPGTtVsI8zG82JqWQa68woYQH"; - - /** - * Real signature using fake secret key. - */ - String signature = "5ed1673e34421217a5dbfcad905ee62261a3dd66c442f3edd19302072bbf70d0"; - - /** - * File which the signature applies to. - */ - Path filePath = getV1ResourcePath("async/get_completed_empty.json"); - - @Test - void loadDocument_withFile_mustReturnValidLocalResponse() throws IOException { - LocalResponse localResponse = new LocalResponse(new File(this.filePath.toString())); - Assertions.assertNotNull(localResponse.getFile()); - Assertions - .assertFalse( - localResponse.isValidHmacSignature(this.secretKey, "invalid signature is invalid") - ); - Assertions.assertEquals(this.signature, localResponse.getHmacSignature(this.secretKey)); - Assertions.assertTrue(localResponse.isValidHmacSignature(this.secretKey, this.signature)); - } - - @Test - void loadDocument_withString_mustReturnValidLocalResponse() { - LocalResponse localResponse = new LocalResponse("{'some': 'json', 'with': 'data'}"); - Assertions.assertNotNull(localResponse.getFile()); - Assertions - .assertFalse( - localResponse.isValidHmacSignature(this.secretKey, "invalid signature is invalid") - ); - } - - @Test - void loadDocument_withInputStream_mustReturnValidLocalResponse() throws IOException { - LocalResponse localResponse = new LocalResponse(Files.newInputStream(this.filePath)); - Assertions.assertNotNull(localResponse.getFile()); - Assertions - .assertFalse( - localResponse.isValidHmacSignature(this.secretKey, "invalid signature is invalid") - ); - Assertions.assertEquals(this.signature, localResponse.getHmacSignature(this.secretKey)); - Assertions.assertTrue(localResponse.isValidHmacSignature(this.secretKey, this.signature)); - } -} diff --git a/src/test/java/com/mindee/v1/MindeeClientTest.java b/src/test/java/com/mindee/v1/MindeeClientTest.java index 4bf21570c..c2cc65079 100644 --- a/src/test/java/com/mindee/v1/MindeeClientTest.java +++ b/src/test/java/com/mindee/v1/MindeeClientTest.java @@ -1,11 +1,8 @@ package com.mindee.v1; -import static com.mindee.TestingUtilities.assertStringEqualsFile; import static com.mindee.TestingUtilities.getResourcePath; -import static com.mindee.TestingUtilities.getV1ResourcePathString; import com.mindee.input.LocalInputSource; -import com.mindee.input.LocalResponse; import com.mindee.input.PageOptions; import com.mindee.input.PageOptionsOperation; import com.mindee.v1.clientOptions.PredictOptions; @@ -13,9 +10,7 @@ import com.mindee.v1.parsing.common.Document; import com.mindee.v1.parsing.common.Job; import com.mindee.v1.parsing.common.PredictResponse; -import com.mindee.v1.product.internationalid.InternationalIdV2; import com.mindee.v1.product.invoice.InvoiceV4; -import java.io.File; import java.io.IOException; import java.net.URL; import java.nio.file.Files; @@ -156,30 +151,4 @@ void givenAnAsyncUrl_whenEnqueued_shouldInvokeApiCorrectly() throws IOException Assertions.assertEquals("someid", jobId); } - - @Test - void givenJsonInput_whenSync_shouldDeserializeCorrectly() throws IOException { - File file = new File(getV1ResourcePathString("products/invoices/response_v4/complete.json")); - LocalResponse localResponse = new LocalResponse(file); - AsyncPredictResponse predictResponse = new MindeeClient() - .loadPrediction(InvoiceV4.class, localResponse); - assertStringEqualsFile( - predictResponse.getDocumentObj().toString(), - getV1ResourcePathString("/products/invoices/response_v4/summary_full.rst") - ); - } - - @Test - void givenJsonInput_whenAsync_shouldDeserializeCorrectly() throws IOException { - File file = new File( - getV1ResourcePathString("products/international_id/response_v2/complete.json") - ); - LocalResponse localResponse = new LocalResponse(file); - AsyncPredictResponse predictResponse = new MindeeClient() - .loadPrediction(InternationalIdV2.class, localResponse); - assertStringEqualsFile( - predictResponse.getDocumentObj().toString(), - getV1ResourcePathString("products/international_id/response_v2/summary_full.rst") - ); - } } diff --git a/src/test/java/com/mindee/v1/parsing/LocalResponseTest.java b/src/test/java/com/mindee/v1/parsing/LocalResponseTest.java new file mode 100644 index 000000000..981fb194b --- /dev/null +++ b/src/test/java/com/mindee/v1/parsing/LocalResponseTest.java @@ -0,0 +1,101 @@ +package com.mindee.v1.parsing; + +import static com.mindee.TestingUtilities.assertStringEqualsFile; +import static com.mindee.TestingUtilities.getV1ResourcePath; +import static com.mindee.TestingUtilities.getV1ResourcePathString; + +import com.mindee.MindeeException; +import com.mindee.v1.product.internationalid.InternationalIdV2; +import com.mindee.v1.product.invoice.InvoiceV4; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class LocalResponseTest { + /** + * Fake secret key. + */ + String secretKey = "ogNjY44MhvKPGTtVsI8zG82JqWQa68woYQH"; + + /** + * Real signature using a fake secret key. + */ + String signature = "5ed1673e34421217a5dbfcad905ee62261a3dd66c442f3edd19302072bbf70d0"; + + /** + * File that the signature applies to. + */ + Path filePath = getV1ResourcePath("async/get_completed_empty.json"); + + @Test + void loadDocument_withFile_mustReturnValidLocalResponse() throws IOException { + var localResponse = new LocalResponse(new File(this.filePath.toString())); + Assertions.assertNotNull(localResponse.getFile()); + Assertions + .assertFalse( + localResponse.isValidHmacSignature(this.secretKey, "invalid signature is invalid") + ); + Assertions.assertEquals(this.signature, localResponse.getHmacSignature(this.secretKey)); + Assertions.assertTrue(localResponse.isValidHmacSignature(this.secretKey, this.signature)); + } + + @Test + void loadDocument_withString_mustReturnValidLocalResponse() { + var localResponse = new LocalResponse("{'some': 'json', 'with': 'data'}"); + Assertions.assertNotNull(localResponse.getFile()); + Assertions + .assertFalse( + localResponse.isValidHmacSignature(this.secretKey, "invalid signature is invalid") + ); + } + + @Test + void loadDocument_withInputStream_mustReturnValidLocalResponse() throws IOException { + var localResponse = new LocalResponse(Files.newInputStream(this.filePath)); + Assertions.assertNotNull(localResponse.getFile()); + Assertions + .assertFalse( + localResponse.isValidHmacSignature(this.secretKey, "invalid signature is invalid") + ); + Assertions.assertEquals(this.signature, localResponse.getHmacSignature(this.secretKey)); + Assertions.assertTrue(localResponse.isValidHmacSignature(this.secretKey, this.signature)); + } + + @Test + void givenJsonInput_whenSync_shouldDeserializeCorrectly() throws IOException { + var localResponse = new LocalResponse( + getV1ResourcePath("products/invoices/response_v4/complete.json") + ); + var response = localResponse.deserializeSyncResponse(InvoiceV4.class); + assertStringEqualsFile( + response.getDocument().toString(), + getV1ResourcePath("/products/invoices/response_v4/summary_full.rst") + ); + } + + @Test + void givenJsonInput_whenAsync_shouldDeserializeCorrectly() throws IOException { + var localResponse = new LocalResponse( + getV1ResourcePath("products/international_id/response_v2/complete.json") + ); + var response = localResponse.deserializeAsyncResponse(InternationalIdV2.class); + assertStringEqualsFile( + response.getDocumentObj().toString(), + getV1ResourcePathString("products/international_id/response_v2/summary_full.rst") + ); + } + + @Test + void givenInvalidJsonInput_shouldThrow() { + var localResponse = new LocalResponse("{invalid json"); + var err = Assertions + .assertThrows( + MindeeException.class, + () -> localResponse.deserializeSyncResponse(InvoiceV4.class) + ); + Assertions.assertEquals("Invalid JSON payload.", err.getMessage()); + } +} diff --git a/src/test/java/com/mindee/v2/MindeeClientTest.java b/src/test/java/com/mindee/v2/MindeeClientTest.java index 0696fde08..b3e5f1da6 100644 --- a/src/test/java/com/mindee/v2/MindeeClientTest.java +++ b/src/test/java/com/mindee/v2/MindeeClientTest.java @@ -7,7 +7,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.mindee.input.LocalInputSource; -import com.mindee.input.LocalResponse; import com.mindee.input.URLInputSource; import com.mindee.v2.clientOptions.BaseParameters; import com.mindee.v2.http.MindeeApiV2; @@ -34,18 +33,12 @@ public FakeMindeeApiV2(JobResponse jobResponse, CommonResponse resultResponse) { } @Override - public JobResponse reqPostEnqueue( - LocalInputSource inputSource, - BaseParameters options - ) throws IOException { + public JobResponse reqPostEnqueue(LocalInputSource inputSource, BaseParameters options) { return jobResponse; } @Override - public JobResponse reqPostEnqueue( - URLInputSource inputSource, - BaseParameters options - ) throws IOException { + public JobResponse reqPostEnqueue(URLInputSource inputSource, BaseParameters options) { return jobResponse; } @@ -136,36 +129,4 @@ void document_getResult_async() throws IOException { ); } } - - @Nested - @DisplayName("deserializeResponse()") - class DeserializeResponse { - - @Test - @DisplayName("parses local JSON and exposes correct field values") - void inference_loadsLocally() throws IOException { - var localResponse = new LocalResponse( - getResourcePath("v2/products/extraction/financial_document/complete.json") - ); - ExtractionResponse loaded = localResponse.deserializeResponse(ExtractionResponse.class); - - assertNotNull(loaded, "Loaded InferenceResponse must not be null"); - assertEquals( - "12345678-1234-1234-1234-123456789abc", - loaded.getInference().getModel().getId(), - "Model Id mismatch" - ); - assertEquals( - "John Smith", - loaded - .getInference() - .getResult() - .getFields() - .get("supplier_name") - .getSimpleField() - .getValue(), - "Supplier name mismatch" - ); - } - } } diff --git a/src/test/java/com/mindee/input/LocalResponseV2Test.java b/src/test/java/com/mindee/v2/input/LocalResponseTest.java similarity index 75% rename from src/test/java/com/mindee/input/LocalResponseV2Test.java rename to src/test/java/com/mindee/v2/input/LocalResponseTest.java index 5213d31aa..860d83095 100644 --- a/src/test/java/com/mindee/input/LocalResponseV2Test.java +++ b/src/test/java/com/mindee/v2/input/LocalResponseTest.java @@ -1,7 +1,8 @@ -package com.mindee.input; +package com.mindee.v2.input; import static com.mindee.TestingUtilities.getV2ResourcePath; +import com.mindee.v2.parsing.LocalResponse; import com.mindee.v2.product.extraction.ExtractionResponse; import java.io.File; import java.io.IOException; @@ -10,19 +11,19 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class LocalResponseV2Test { +public class LocalResponseTest { /** * Fake secret key. */ String secretKey = "ogNjY44MhvKPGTtVsI8zG82JqWQa68woYQH"; /** - * Real signature using fake secret key. + * Real signature using a fake secret key. */ String signature = "e51bdf80f1a08ed44ee161100fc30a25cb35b4ede671b0a575dc9064a3f5dbf1"; /** - * File which the signature applies to. + * File that the signature applies to. */ Path filePath = getV2ResourcePath("products/extraction/standard_field_types.json"); @@ -34,20 +35,19 @@ protected void assertLocalResponse(LocalResponse localResponse) { ); Assertions.assertEquals(this.signature, localResponse.getHmacSignature(this.secretKey)); Assertions.assertTrue(localResponse.isValidHmacSignature(this.secretKey, this.signature)); - ExtractionResponse response = localResponse.deserializeResponse(ExtractionResponse.class); + var response = localResponse.deserializeResponse(ExtractionResponse.class); Assertions.assertNotNull(response); Assertions.assertNotNull(response.getInference()); } @Test void loadDocument_withFile_mustReturnValidLocalResponse() throws IOException { - LocalResponse localResponse = new LocalResponse(new File(this.filePath.toString())); - assertLocalResponse(localResponse); + assertLocalResponse(new LocalResponse(new File(this.filePath.toString()))); } @Test void loadDocument_withString_mustReturnValidLocalResponse() { - LocalResponse localResponse = new LocalResponse("{'some': 'json', 'with': 'data'}"); + var localResponse = new LocalResponse("{'some': 'json', 'with': 'data'}"); Assertions.assertNotNull(localResponse.getFile()); Assertions .assertFalse( @@ -57,7 +57,7 @@ void loadDocument_withString_mustReturnValidLocalResponse() { @Test void loadDocument_withInputStream_mustReturnValidLocalResponse() throws IOException { - LocalResponse localResponse = new LocalResponse(Files.newInputStream(this.filePath)); + var localResponse = new LocalResponse(Files.newInputStream(this.filePath)); assertLocalResponse(localResponse); } } diff --git a/src/test/java/com/mindee/v2/parsing/JobTest.java b/src/test/java/com/mindee/v2/parsing/JobTest.java index 87f27fd26..77e97ffd1 100644 --- a/src/test/java/com/mindee/v2/parsing/JobTest.java +++ b/src/test/java/com/mindee/v2/parsing/JobTest.java @@ -5,7 +5,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -import com.mindee.input.LocalResponse; import java.io.IOException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; diff --git a/src/test/java/com/mindee/v2/parsing/LocalResponseTest.java b/src/test/java/com/mindee/v2/parsing/LocalResponseTest.java new file mode 100644 index 000000000..ad59a14e3 --- /dev/null +++ b/src/test/java/com/mindee/v2/parsing/LocalResponseTest.java @@ -0,0 +1,50 @@ +package com.mindee.v2.parsing; + +import static com.mindee.TestingUtilities.getResourcePath; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import com.mindee.MindeeException; +import com.mindee.v2.product.extraction.ExtractionResponse; +import java.io.IOException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class LocalResponseTest { + @Test + void loadDocument_withPath_mustReturnValidLocalResponse() throws IOException { + var localResponse = new LocalResponse( + getResourcePath("v2/products/extraction/financial_document/complete.json") + ); + ExtractionResponse loaded = localResponse.deserializeResponse(ExtractionResponse.class); + + assertNotNull(loaded, "Loaded InferenceResponse must not be null"); + assertEquals( + "12345678-1234-1234-1234-123456789abc", + loaded.getInference().getModel().getId(), + "Model Id mismatch" + ); + assertEquals( + "John Smith", + loaded + .getInference() + .getResult() + .getFields() + .get("supplier_name") + .getSimpleField() + .getValue(), + "Supplier name mismatch" + ); + } + + @Test + void givenInvalidJsonInput_shouldThrow() { + var localResponse = new LocalResponse("{invalid json"); + var err = Assertions + .assertThrows( + MindeeException.class, + () -> localResponse.deserializeResponse(ExtractionResponse.class) + ); + Assertions.assertEquals("Invalid JSON payload.", err.getMessage()); + } +} diff --git a/src/test/java/com/mindee/v2/product/ClassificationTest.java b/src/test/java/com/mindee/v2/product/ClassificationTest.java index d7701c82c..624b5020b 100644 --- a/src/test/java/com/mindee/v2/product/ClassificationTest.java +++ b/src/test/java/com/mindee/v2/product/ClassificationTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import com.mindee.input.LocalResponse; +import com.mindee.v2.parsing.LocalResponse; import com.mindee.v2.product.classification.ClassificationResponse; import java.io.IOException; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/com/mindee/v2/product/CropTest.java b/src/test/java/com/mindee/v2/product/CropTest.java index b171a1653..5798aa523 100644 --- a/src/test/java/com/mindee/v2/product/CropTest.java +++ b/src/test/java/com/mindee/v2/product/CropTest.java @@ -5,7 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import com.mindee.input.LocalResponse; +import com.mindee.v2.parsing.LocalResponse; import com.mindee.v2.product.crop.CropResponse; import java.io.IOException; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/com/mindee/v2/parsing/ExtractionTest.java b/src/test/java/com/mindee/v2/product/ExtractionTest.java similarity index 99% rename from src/test/java/com/mindee/v2/parsing/ExtractionTest.java rename to src/test/java/com/mindee/v2/product/ExtractionTest.java index 9927d20aa..724e37639 100644 --- a/src/test/java/com/mindee/v2/parsing/ExtractionTest.java +++ b/src/test/java/com/mindee/v2/product/ExtractionTest.java @@ -1,4 +1,4 @@ -package com.mindee.v2.parsing; +package com.mindee.v2.product; import static com.mindee.TestingUtilities.getV2ResourcePath; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -11,7 +11,7 @@ import com.mindee.geometry.Point; import com.mindee.geometry.Polygon; -import com.mindee.input.LocalResponse; +import com.mindee.v2.parsing.LocalResponse; import com.mindee.v2.parsing.inference.InferenceActiveOptions; import com.mindee.v2.parsing.inference.InferenceFile; import com.mindee.v2.parsing.inference.InferenceJob; diff --git a/src/test/java/com/mindee/v2/product/OcrTest.java b/src/test/java/com/mindee/v2/product/OcrTest.java index ef734eec0..ae269073e 100644 --- a/src/test/java/com/mindee/v2/product/OcrTest.java +++ b/src/test/java/com/mindee/v2/product/OcrTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import com.mindee.input.LocalResponse; +import com.mindee.v2.parsing.LocalResponse; import com.mindee.v2.product.ocr.OcrResponse; import java.io.IOException; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/com/mindee/v2/product/SplitTest.java b/src/test/java/com/mindee/v2/product/SplitTest.java index d4ff870d1..b3db37ff4 100644 --- a/src/test/java/com/mindee/v2/product/SplitTest.java +++ b/src/test/java/com/mindee/v2/product/SplitTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import com.mindee.input.LocalResponse; +import com.mindee.v2.parsing.LocalResponse; import com.mindee.v2.product.split.SplitResponse; import java.io.IOException; import org.junit.jupiter.api.DisplayName; From 1dd0f3c239444e35808a33ab937ab014cc0dc4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Wed, 8 Apr 2026 16:52:54 +0200 Subject: [PATCH 7/9] :recycle: simplify polygon utilities, :boom: prefer objects over static classes (#312) --- src/main/java/com/mindee/geometry/Bbox.java | 5 +- .../java/com/mindee/geometry/BboxUtils.java | 31 ++----- .../com/mindee/geometry/BoundingBoxUtils.java | 36 ------- .../java/com/mindee/geometry/Polygon.java | 27 ++++-- .../com/mindee/geometry/PolygonUtils.java | 93 ++++--------------- .../java/com/mindee/http/MindeeApiCommon.java | 7 +- .../java/com/mindee/image/ExtractedImage.java | 11 +-- .../com/mindee/image/ImageCompressor.java | 30 +++--- .../java/com/mindee/image/ImageExtractor.java | 10 +- .../com/mindee/input/LocalInputSource.java | 4 +- .../mindee/input/PageOptionsOperation.java | 4 +- .../com/mindee/parsing/SummaryHelper.java | 2 +- .../java/com/mindee/pdf/ExtractedPDF.java | 7 +- .../mindee/v1/parsing/standard/BaseField.java | 5 +- .../mindee/geometry/BoundingBoxUtilsTest.java | 15 +-- 15 files changed, 84 insertions(+), 203 deletions(-) delete mode 100644 src/main/java/com/mindee/geometry/BoundingBoxUtils.java diff --git a/src/main/java/com/mindee/geometry/Bbox.java b/src/main/java/com/mindee/geometry/Bbox.java index 4f4f3dd8b..79e804277 100644 --- a/src/main/java/com/mindee/geometry/Bbox.java +++ b/src/main/java/com/mindee/geometry/Bbox.java @@ -1,6 +1,5 @@ package com.mindee.geometry; -import java.util.Arrays; import java.util.List; import lombok.Getter; @@ -34,8 +33,8 @@ public Bbox(double minX, double maxX, double minY, double maxY) { * Get the Bbox as a Polygon. */ public Polygon getAsPolygon() { - List points = Arrays - .asList( + var points = List + .of( new Point(this.minX, this.minY), new Point(this.maxX, this.minY), new Point(this.maxX, this.maxY), diff --git a/src/main/java/com/mindee/geometry/BboxUtils.java b/src/main/java/com/mindee/geometry/BboxUtils.java index 0b4ca8bcd..98802a90f 100644 --- a/src/main/java/com/mindee/geometry/BboxUtils.java +++ b/src/main/java/com/mindee/geometry/BboxUtils.java @@ -1,8 +1,6 @@ package com.mindee.geometry; -import java.util.DoubleSummaryStatistics; import java.util.List; -import java.util.Optional; /** * Methods for working with BBoxes. @@ -20,17 +18,8 @@ public static Bbox generate(Polygon polygon) { return null; } - DoubleSummaryStatistics statsX = polygon - .getCoordinates() - .stream() - .mapToDouble(Point::getX) - .summaryStatistics(); - - DoubleSummaryStatistics statsY = polygon - .getCoordinates() - .stream() - .mapToDouble(Point::getY) - .summaryStatistics(); + var statsX = polygon.getCoordinates().stream().mapToDouble(Point::getX).summaryStatistics(); + var statsY = polygon.getCoordinates().stream().mapToDouble(Point::getY).summaryStatistics(); return new Bbox(statsX.getMin(), statsX.getMax(), statsY.getMin(), statsY.getMax()); } @@ -44,13 +33,7 @@ public static Bbox generate(List polygons) { return null; } - Optional mergedPolygon = polygons.stream().reduce(PolygonUtils::combine); - - if (!mergedPolygon.isPresent()) { - return null; - } - - return generate(mergedPolygon.get()); + return polygons.stream().reduce(PolygonUtils::combine).map(BboxUtils::generate).orElse(null); } /** @@ -62,10 +45,10 @@ public static Bbox merge(List bboxes) { } return new Bbox( - bboxes.stream().map(Bbox::getMinX).min(Double::compare).get(), - bboxes.stream().map(Bbox::getMaxX).max(Double::compare).get(), - bboxes.stream().map(Bbox::getMinY).min(Double::compare).get(), - bboxes.stream().map(Bbox::getMaxY).max(Double::compare).get() + bboxes.stream().mapToDouble(Bbox::getMinX).min().getAsDouble(), + bboxes.stream().mapToDouble(Bbox::getMaxX).max().getAsDouble(), + bboxes.stream().mapToDouble(Bbox::getMinY).min().getAsDouble(), + bboxes.stream().mapToDouble(Bbox::getMaxY).max().getAsDouble() ); } diff --git a/src/main/java/com/mindee/geometry/BoundingBoxUtils.java b/src/main/java/com/mindee/geometry/BoundingBoxUtils.java deleted file mode 100644 index d4b8e31bf..000000000 --- a/src/main/java/com/mindee/geometry/BoundingBoxUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.mindee.geometry; - -import java.util.Arrays; -import java.util.DoubleSummaryStatistics; - -/** - * Methods for working with BoundingBoxes. - */ -public final class BoundingBoxUtils { - private BoundingBoxUtils() { - } - - public static Polygon createBoundingBoxFrom(Polygon polygon) { - DoubleSummaryStatistics xStatistics = polygon - .getCoordinates() - .stream() - .mapToDouble(Point::getX) - .summaryStatistics(); - - DoubleSummaryStatistics yStatistics = polygon - .getCoordinates() - .stream() - .mapToDouble(Point::getY) - .summaryStatistics(); - - return new Polygon( - Arrays - .asList( - new Point(xStatistics.getMin(), yStatistics.getMin()), - new Point(xStatistics.getMax(), yStatistics.getMin()), - new Point(xStatistics.getMax(), yStatistics.getMax()), - new Point(xStatistics.getMin(), yStatistics.getMax()) - ) - ); - } -} diff --git a/src/main/java/com/mindee/geometry/Polygon.java b/src/main/java/com/mindee/geometry/Polygon.java index 168fbb6f2..0c2a64b6e 100644 --- a/src/main/java/com/mindee/geometry/Polygon.java +++ b/src/main/java/com/mindee/geometry/Polygon.java @@ -42,6 +42,23 @@ public Bbox getAsBbox() { return BboxUtils.generate(this); } + /** + * Get a bounding box that encloses the Polygon. + */ + public Polygon getBoundingBox() { + var minMaxX = getMinMaxX(); + var minMaxY = getMinMaxY(); + return new Polygon( + List + .of( + new Point(minMaxX.getMin(), minMaxY.getMin()), + new Point(minMaxX.getMax(), minMaxY.getMin()), + new Point(minMaxX.getMax(), minMaxY.getMax()), + new Point(minMaxX.getMin(), minMaxY.getMax()) + ) + ); + } + /** * Get the central coordinates (centroid) of the Polygon. */ @@ -84,15 +101,7 @@ public String toString() { * String representation with precise coordinates. */ public String toStringPrecise() { - StringBuilder builder = new StringBuilder("("); - for (int i = 0; i < coordinates.size(); i++) { - if (i > 0) { - builder.append(", "); - } - builder.append(coordinates.get(i)); - } - builder.append(")"); - return builder.toString(); + return coordinates.stream().map(Point::toString).collect(Collectors.joining(", ", "(", ")")); } /** diff --git a/src/main/java/com/mindee/geometry/PolygonUtils.java b/src/main/java/com/mindee/geometry/PolygonUtils.java index dd5a8c977..6fb017d72 100644 --- a/src/main/java/com/mindee/geometry/PolygonUtils.java +++ b/src/main/java/com/mindee/geometry/PolygonUtils.java @@ -1,7 +1,5 @@ package com.mindee.geometry; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -19,8 +17,8 @@ private PolygonUtils() { public static Point getCentroid(List vertices) { int verticesSum = vertices.size(); - double xSum = vertices.stream().map(Point::getX).mapToDouble(Double::doubleValue).sum(); - double ySum = vertices.stream().map(Point::getY).mapToDouble(Double::doubleValue).sum(); + double xSum = vertices.stream().mapToDouble(Point::getX).sum(); + double ySum = vertices.stream().mapToDouble(Point::getY).sum(); return new Point(xSum / verticesSum, ySum / verticesSum); } @@ -28,16 +26,16 @@ public static Point getCentroid(List vertices) { * Get the maximum and minimum Y coordinates in a given list of Points. */ public static MinMax getMinMaxY(List vertices) { - List points = vertices.stream().map(Point::getY).collect(Collectors.toList()); - return new MinMax(Collections.min(points), Collections.max(points)); + var stats = vertices.stream().mapToDouble(Point::getY).summaryStatistics(); + return new MinMax(stats.getMin(), stats.getMax()); } /** * Get the maximum and minimum X coordinates in a given list of Points. */ public static MinMax getMinMaxX(List vertices) { - List points = vertices.stream().map(Point::getX).collect(Collectors.toList()); - return new MinMax(Collections.min(points), Collections.max(points)); + var stats = vertices.stream().mapToDouble(Point::getX).summaryStatistics(); + return new MinMax(stats.getMin(), stats.getMax()); } /** @@ -70,77 +68,20 @@ public static Polygon combine(Polygon base, Polygon target) { target = base; } - Double maxx = Math - .max( - target - .getCoordinates() - .stream() - .map(Point::getX) - .max(Double::compareTo) - .orElse(Double.MIN_VALUE), - base - .getCoordinates() - .stream() - .map(Point::getX) - .max(Double::compareTo) - .orElse(Double.MIN_VALUE) - ); + var combinedCoords = java.util.stream.Stream + .concat(base.getCoordinates().stream(), target.getCoordinates().stream()) + .collect(Collectors.toList()); - Double minx = Math - .min( - target - .getCoordinates() - .stream() - .map(Point::getX) - .min(Double::compareTo) - .orElse(Double.MAX_VALUE), - base - .getCoordinates() - .stream() - .map(Point::getX) - .min(Double::compareTo) - .orElse(Double.MAX_VALUE) - ); - - Double maxy = Math - .max( - target - .getCoordinates() - .stream() - .map(Point::getY) - .max(Double::compareTo) - .orElse(Double.MIN_VALUE), - base - .getCoordinates() - .stream() - .map(Point::getY) - .max(Double::compareTo) - .orElse(Double.MIN_VALUE) - ); - - Double miny = Math - .min( - target - .getCoordinates() - .stream() - .map(Point::getY) - .min(Double::compareTo) - .orElse(Double.MAX_VALUE), - base - .getCoordinates() - .stream() - .map(Point::getY) - .min(Double::compareTo) - .orElse(Double.MAX_VALUE) - ); + var xStats = combinedCoords.stream().mapToDouble(Point::getX).summaryStatistics(); + var yStats = combinedCoords.stream().mapToDouble(Point::getY).summaryStatistics(); return new Polygon( - Arrays - .asList( - new Point(minx, miny), - new Point(maxx, miny), - new Point(maxx, maxy), - new Point(minx, maxy) + List + .of( + new Point(xStats.getMin(), yStats.getMin()), + new Point(xStats.getMax(), yStats.getMin()), + new Point(xStats.getMax(), yStats.getMax()), + new Point(xStats.getMin(), yStats.getMax()) ) ); } diff --git a/src/main/java/com/mindee/http/MindeeApiCommon.java b/src/main/java/com/mindee/http/MindeeApiCommon.java index 0f3c68632..62e3574e8 100644 --- a/src/main/java/com/mindee/http/MindeeApiCommon.java +++ b/src/main/java/com/mindee/http/MindeeApiCommon.java @@ -2,6 +2,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import org.apache.hc.core5.http.HttpEntity; /** @@ -10,7 +11,7 @@ public abstract class MindeeApiCommon { /** * Retrieves the user agent. - * + * * @return the user agent. */ protected String getUserAgent() { @@ -36,7 +37,7 @@ protected String getUserAgent() { /** * Checks if the status code is out of the 2xx-3xx range. - * + * * @param statusCode the status code to check. * @return {@code true} if the status code is in the 2xx range, false otherwise. */ @@ -50,6 +51,6 @@ protected String readRawResponse(HttpEntity responseEntity) throws IOException { for (int length; (length = responseEntity.getContent().read(buffer)) != -1;) { contentRead.write(buffer, 0, length); } - return contentRead.toString("UTF-8"); + return contentRead.toString(StandardCharsets.UTF_8); } } diff --git a/src/main/java/com/mindee/image/ExtractedImage.java b/src/main/java/com/mindee/image/ExtractedImage.java index 76540a8a3..319f98f5d 100644 --- a/src/main/java/com/mindee/image/ExtractedImage.java +++ b/src/main/java/com/mindee/image/ExtractedImage.java @@ -3,7 +3,6 @@ import com.mindee.input.LocalInputSource; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; @@ -40,9 +39,7 @@ public ExtractedImage(BufferedImage image, String filename, String saveFormat) { * @throws IOException Throws if the file can't be accessed. */ public void writeToFile(String outputPath) throws IOException { - Path imagePath = Paths.get(outputPath, this.filename); - File outputfile = imagePath.toFile(); - ImageIO.write(this.image, this.saveFormat, outputfile); + writeToFile(Paths.get(outputPath)); } /** @@ -53,8 +50,8 @@ public void writeToFile(String outputPath) throws IOException { * @throws IOException Throws if the file can't be accessed. */ public void writeToFile(Path outputPath) throws IOException { - Path imagePath = outputPath.resolve(this.filename); - File outputfile = imagePath.toFile(); + var imagePath = outputPath.resolve(this.filename); + var outputfile = imagePath.toFile(); ImageIO.write(this.image, this.saveFormat, outputfile); } @@ -65,7 +62,7 @@ public void writeToFile(Path outputPath) throws IOException { * @throws IOException Throws if the file can't be accessed. */ public LocalInputSource asInputSource() throws IOException { - ByteArrayOutputStream output = new ByteArrayOutputStream(); + var output = new ByteArrayOutputStream(); ImageIO.write(this.image, this.saveFormat, output); return new LocalInputSource(output.toByteArray(), this.filename); } diff --git a/src/main/java/com/mindee/image/ImageCompressor.java b/src/main/java/com/mindee/image/ImageCompressor.java index 8a58231d4..b56096322 100644 --- a/src/main/java/com/mindee/image/ImageCompressor.java +++ b/src/main/java/com/mindee/image/ImageCompressor.java @@ -1,12 +1,10 @@ package com.mindee.image; -import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.Iterator; import javax.imageio.IIOImage; import javax.imageio.ImageIO; import javax.imageio.ImageWriteParam; @@ -21,10 +19,10 @@ public static BufferedImage resize( Integer newWidth, Integer newHeight ) { - Image scaledImage = inputImage.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH); - BufferedImage outImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB); + var scaledImage = inputImage.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH); + var outImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB); - Graphics2D g2d = outImage.createGraphics(); + var g2d = outImage.createGraphics(); g2d.drawImage(scaledImage, 0, 0, null); g2d.dispose(); @@ -38,8 +36,8 @@ public static byte[] compressImage( Integer maxHeight ) throws IOException { - ByteArrayInputStream bis = new ByteArrayInputStream(imageData); - BufferedImage original = ImageIO.read(bis); + var bis = new ByteArrayInputStream(imageData); + var original = ImageIO.read(bis); ImageUtils.Dimensions dimensions = ImageUtils .calculateNewDimensions(original, maxWidth, maxHeight); return compressImage(original, quality, dimensions.width, dimensions.height); @@ -70,7 +68,7 @@ public static byte[] compressImage( if (quality == null) { quality = 85; } - BufferedImage resizedImage = resize(original, finalWidth, finalHeight); + var resizedImage = resize(original, finalWidth, finalHeight); return encodeToJpegByteArray(resizedImage, (float) quality / 100f); } @@ -78,14 +76,14 @@ public static BufferedImage removeAlphaChannel(BufferedImage original) { if (original.getType() == BufferedImage.TYPE_INT_RGB) { return original; } - BufferedImage newImage = new BufferedImage( + var newImage = new BufferedImage( original.getWidth(), original.getHeight(), BufferedImage.TYPE_INT_RGB ); - Graphics2D g = newImage.createGraphics(); - g.drawImage(original, 0, 0, null); - g.dispose(); + var graphics = newImage.createGraphics(); + graphics.drawImage(original, 0, 0, null); + graphics.dispose(); return newImage; } @@ -93,17 +91,17 @@ public static byte[] encodeToJpegByteArray( BufferedImage image, float quality ) throws IOException { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + var outputStream = new ByteArrayOutputStream(); - Iterator writers = ImageIO.getImageWritersByFormatName("jpg"); + var writers = ImageIO.getImageWritersByFormatName("jpg"); ImageWriter writer = writers.next(); - ImageWriteParam params = writer.getDefaultWriteParam(); + var params = writer.getDefaultWriteParam(); params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); params.setCompressionQuality(quality); writer.setOutput(ImageIO.createImageOutputStream(outputStream)); - BufferedImage alphaCheckedImage = removeAlphaChannel(image); + var alphaCheckedImage = removeAlphaChannel(image); writer.write(null, new IIOImage(alphaCheckedImage, null, null), params); writer.dispose(); diff --git a/src/main/java/com/mindee/image/ImageExtractor.java b/src/main/java/com/mindee/image/ImageExtractor.java index 8dcb6b181..24ea7b15b 100644 --- a/src/main/java/com/mindee/image/ImageExtractor.java +++ b/src/main/java/com/mindee/image/ImageExtractor.java @@ -44,7 +44,7 @@ public ImageExtractor(LocalInputSource source) throws IOException { if (source.isPdf()) { this.saveFormat = "jpg"; - List pdfPageImages = PDFUtils.pdfToImages(source); + var pdfPageImages = PDFUtils.pdfToImages(source); for (PdfPageImage pdfPageImage : pdfPageImages) { this.pageImages.add(pdfPageImage.getImage()); } @@ -52,7 +52,7 @@ public ImageExtractor(LocalInputSource source) throws IOException { String[] splitName = InputSourceUtils.splitNameStrict(this.filename); this.saveFormat = splitName[1].toLowerCase(); - ByteArrayInputStream input = new ByteArrayInputStream(source.getFile()); + var input = new ByteArrayInputStream(source.getFile()); this.pageImages.add(ImageIO.read(input)); } } @@ -111,11 +111,11 @@ private List extractFromPage( String outputName ) { String[] splitName = InputSourceUtils.splitNameStrict(outputName); - String filename = String + var filename = String .format("%s_page-%3s.%s", splitName[0], pageIndex + 1, splitName[1]) .replace(" ", "0"); - List extractedImages = new ArrayList<>(); + var extractedImages = new ArrayList(); for (int i = 0; i < fields.size(); i++) { ExtractedImage extractedImage = extractImage(fields.get(i), pageIndex, i + 1, filename); if (extractedImage != null) { @@ -178,7 +178,7 @@ public ExtractedImage extractImage( } private BufferedImage extractImage(Bbox bbox, int pageIndex) { - BufferedImage image = this.pageImages.get(pageIndex); + var image = this.pageImages.get(pageIndex); int width = image.getWidth(); int height = image.getHeight(); int minX = (int) Math.round(bbox.getMinX() * width); diff --git a/src/main/java/com/mindee/input/LocalInputSource.java b/src/main/java/com/mindee/input/LocalInputSource.java index 46fc006c4..b5f0169ad 100644 --- a/src/main/java/com/mindee/input/LocalInputSource.java +++ b/src/main/java/com/mindee/input/LocalInputSource.java @@ -30,7 +30,7 @@ public LocalInputSource(InputStream file, String filename) throws IOException { } public LocalInputSource(String filePath) throws IOException { - File file = new File(filePath); + var file = new File(filePath); this.file = Files.readAllBytes(file.toPath()); this.filename = file.getName(); } @@ -57,7 +57,7 @@ public LocalInputSource(String fileAsBase64, String filename) { /** * Get the number of pages in the document. - * + * * @return the number of pages in the current file. * @throws IOException If an I/O error occurs during the PDF operation. */ diff --git a/src/main/java/com/mindee/input/PageOptionsOperation.java b/src/main/java/com/mindee/input/PageOptionsOperation.java index d21663d94..7fead0f82 100644 --- a/src/main/java/com/mindee/input/PageOptionsOperation.java +++ b/src/main/java/com/mindee/input/PageOptionsOperation.java @@ -5,11 +5,11 @@ */ public enum PageOptionsOperation { /** - * Keep only the specified pages, and remove all others. + * Keep only the specified pages, removing all others. */ KEEP_ONLY, /** - * Remove the specified pages, and keep all others. + * Remove the specified pages, keeping all others. */ REMOVE } diff --git a/src/main/java/com/mindee/parsing/SummaryHelper.java b/src/main/java/com/mindee/parsing/SummaryHelper.java index dd6cb7f24..1f98b7b2c 100644 --- a/src/main/java/com/mindee/parsing/SummaryHelper.java +++ b/src/main/java/com/mindee/parsing/SummaryHelper.java @@ -72,7 +72,7 @@ public static String formatForDisplay(Boolean inputValue, Integer maxColSize) { * Format an rST table line separator. */ public static String lineSeparator(int[] columnSizes, String str) { - StringBuilder outStr = new StringBuilder(" +"); + var outStr = new StringBuilder(" +"); for (int size : columnSizes) { outStr.append(String.format("%" + size + "s+", "").replace(" ", str)); } diff --git a/src/main/java/com/mindee/pdf/ExtractedPDF.java b/src/main/java/com/mindee/pdf/ExtractedPDF.java index 3041ef143..7bfe24c95 100644 --- a/src/main/java/com/mindee/pdf/ExtractedPDF.java +++ b/src/main/java/com/mindee/pdf/ExtractedPDF.java @@ -4,7 +4,6 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; -import java.nio.file.Path; import java.nio.file.Paths; import lombok.Getter; import org.apache.pdfbox.pdmodel.PDDocument; @@ -35,8 +34,8 @@ public ExtractedPDF(PDDocument pdf, String filename) { * @throws IOException Throws if the file can't be accessed. */ public void writeToFile(String outputPath) throws IOException { - Path pdfPath = Paths.get(outputPath, this.filename); - File outputfile = new File(pdfPath.toString()); + var pdfPath = Paths.get(outputPath, this.filename); + var outputfile = new File(pdfPath.toString()); this.pdf.save(outputfile); } @@ -47,7 +46,7 @@ public void writeToFile(String outputPath) throws IOException { * @throws IOException Throws if the file can't be accessed. */ public LocalInputSource asInputSource() throws IOException { - ByteArrayOutputStream output = new ByteArrayOutputStream(); + var output = new ByteArrayOutputStream(); this.pdf.save(output); return new LocalInputSource(output.toByteArray(), this.filename); } diff --git a/src/main/java/com/mindee/v1/parsing/standard/BaseField.java b/src/main/java/com/mindee/v1/parsing/standard/BaseField.java index f4fa24f0c..3e8c8af8f 100644 --- a/src/main/java/com/mindee/v1/parsing/standard/BaseField.java +++ b/src/main/java/com/mindee/v1/parsing/standard/BaseField.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.geometry.BoundingBoxUtils; import com.mindee.geometry.Polygon; import com.mindee.geometry.PolygonDeserializer; import com.mindee.geometry.PositionDataField; @@ -54,7 +53,7 @@ protected BaseField( this.polygon = polygon; this.pageId = pageId; if (polygon != null) { - this.boundingBox = BoundingBoxUtils.createBoundingBoxFrom(this.polygon); + this.boundingBox = this.polygon.getBoundingBox(); } else { this.boundingBox = null; } @@ -65,7 +64,7 @@ protected BaseField( */ protected BaseField() { if (polygon != null) { - this.boundingBox = BoundingBoxUtils.createBoundingBoxFrom(this.polygon); + this.boundingBox = this.polygon.getBoundingBox(); } else { this.boundingBox = null; } diff --git a/src/test/java/com/mindee/geometry/BoundingBoxUtilsTest.java b/src/test/java/com/mindee/geometry/BoundingBoxUtilsTest.java index b72afab78..8ea4bb73e 100644 --- a/src/test/java/com/mindee/geometry/BoundingBoxUtilsTest.java +++ b/src/test/java/com/mindee/geometry/BoundingBoxUtilsTest.java @@ -7,22 +7,16 @@ class BoundingBoxUtilsTest { @Test public void bboxFromARectanglePolygonMustHaveALimitedNumberOfCoordinates() { - // given Polygon polygonAsRectangle = PolygonSample.getPolygonAsRectangle(); - - // then - Polygon boundingBox = BoundingBoxUtils.createBoundingBoxFrom(polygonAsRectangle); + Polygon boundingBox = polygonAsRectangle.getBoundingBox(); Assertions.assertEquals(4, boundingBox.getCoordinates().size()); } @Test public void fromARectanglePolygonMustGetAValidBbox() { - // given Polygon polygonAsRectangle = PolygonSample.getPolygonAsRectangle(); - - // then - Polygon boundingBox = BoundingBoxUtils.createBoundingBoxFrom(polygonAsRectangle); + Polygon boundingBox = polygonAsRectangle.getBoundingBox(); Assertions .assertTrue(boundingBox.getCoordinates().stream().anyMatch(c -> c.getX().equals(0.123))); @@ -37,11 +31,8 @@ public void fromARectanglePolygonMustGetAValidBbox() { @Test public void fromPolygonMustGetAValidBbox() { - // given Polygon polygonWichIsNotRectangle = PolygonSample.getPolygonWichIsNotRectangle(); - - // then - Polygon boundingBox = BoundingBoxUtils.createBoundingBoxFrom(polygonWichIsNotRectangle); + Polygon boundingBox = polygonWichIsNotRectangle.getBoundingBox(); Assertions .assertTrue(boundingBox.getCoordinates().stream().anyMatch(c -> c.getX().equals(0.205))); From 169cb4b42124d888e553ae065f25602292ed0661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Thu, 9 Apr 2026 10:09:38 +0200 Subject: [PATCH 8/9] :recycle: :boom: polling options should be version-specific (#313) --- .../java/com/mindee/AsyncPollingOptions.java | 30 --------- .../clientOptions/BasePollingOptions.java | 52 ++++++++++++++ .../mindee/{ => v1}/CommandLineInterface.java | 7 +- src/main/java/com/mindee/v1/MindeeClient.java | 18 ++--- .../v1/clientOptions/PollingOptions.java | 12 ++++ src/main/java/com/mindee/v2/MindeeClient.java | 67 ++++++++++++++++--- .../v2/clientOptions/BaseParameters.java | 24 ------- .../v2/clientOptions/PollingOptions.java | 11 +++ .../params/ClassificationParameters.java | 12 +--- .../product/crop/params/CropParameters.java | 12 +--- .../params/ExtractionParameters.java | 5 +- .../v2/product/ocr/params/OcrParameters.java | 12 +--- .../product/split/params/SplitParameters.java | 12 +--- .../java/com/mindee/v2/MindeeClientIT.java | 15 +++-- .../v2/clientOptions/PollingOptionsTest.java | 40 +++++++++++ .../java/com/mindee/v2/product/CropIT.java | 16 +++-- .../java/com/mindee/v2/product/SplitIT.java | 14 ++-- 17 files changed, 227 insertions(+), 132 deletions(-) delete mode 100644 src/main/java/com/mindee/AsyncPollingOptions.java create mode 100644 src/main/java/com/mindee/clientOptions/BasePollingOptions.java rename src/main/java/com/mindee/{ => v1}/CommandLineInterface.java (98%) create mode 100644 src/main/java/com/mindee/v1/clientOptions/PollingOptions.java create mode 100644 src/main/java/com/mindee/v2/clientOptions/PollingOptions.java create mode 100644 src/test/java/com/mindee/v2/clientOptions/PollingOptionsTest.java diff --git a/src/main/java/com/mindee/AsyncPollingOptions.java b/src/main/java/com/mindee/AsyncPollingOptions.java deleted file mode 100644 index 004c6f72a..000000000 --- a/src/main/java/com/mindee/AsyncPollingOptions.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.mindee; - -import lombok.Builder; -import lombok.Value; - -/** - * Options to pass for asynchronous parsing with polling. - */ -@Value -public class AsyncPollingOptions { - /** - * Wait this many seconds before the first polling attempt. - */ - Double initialDelaySec; - /** - * Wait this many seconds between each polling attempt. - */ - Double intervalSec; - /** - * Maximum number of times to poll. - */ - Integer maxRetries; - - @Builder - private AsyncPollingOptions(Double initialDelaySec, Double intervalSec, Integer maxRetries) { - this.initialDelaySec = initialDelaySec == null ? 2.0 : initialDelaySec; - this.intervalSec = intervalSec == null ? 1.5 : intervalSec; - this.maxRetries = maxRetries == null ? 80 : maxRetries; - } -} diff --git a/src/main/java/com/mindee/clientOptions/BasePollingOptions.java b/src/main/java/com/mindee/clientOptions/BasePollingOptions.java new file mode 100644 index 000000000..1694f3c4b --- /dev/null +++ b/src/main/java/com/mindee/clientOptions/BasePollingOptions.java @@ -0,0 +1,52 @@ +package com.mindee.clientOptions; + +import lombok.Getter; + +/** + * Options to pass for asynchronous parsing with polling. + */ +public abstract class BasePollingOptions { + /** + * Wait this many seconds before the first polling attempt. + */ + @Getter + Double initialDelaySec; + + /** + * Wait this many seconds between each polling attempt. + */ + @Getter + Double intervalSec; + + /** + * Maximum number of times to poll. + */ + @Getter + Integer maxRetries; + + protected BasePollingOptions( + Double initialDelaySec, + Double intervalSec, + Integer maxRetries, + double defaultInitialDelaySec, + double defaultIntervalSec, + int defaultMaxRetries, + double minInitialDelaySec, + double minIntervalSec, + int minMaxRetries + ) { + this.initialDelaySec = initialDelaySec == null ? defaultInitialDelaySec : initialDelaySec; + this.intervalSec = intervalSec == null ? defaultIntervalSec : intervalSec; + this.maxRetries = maxRetries == null ? defaultMaxRetries : maxRetries; + + if (this.initialDelaySec < minInitialDelaySec) { + throw new IllegalArgumentException("Initial delay must be ≥ " + minInitialDelaySec); + } + if (this.intervalSec < minIntervalSec) { + throw new IllegalArgumentException("Interval must be ≥ " + minIntervalSec); + } + if (this.maxRetries < minMaxRetries) { + throw new IllegalArgumentException("Max retries must be ≥ " + minMaxRetries); + } + } +} diff --git a/src/main/java/com/mindee/CommandLineInterface.java b/src/main/java/com/mindee/v1/CommandLineInterface.java similarity index 98% rename from src/main/java/com/mindee/CommandLineInterface.java rename to src/main/java/com/mindee/v1/CommandLineInterface.java index d4957ada6..09c6bfa45 100644 --- a/src/main/java/com/mindee/CommandLineInterface.java +++ b/src/main/java/com/mindee/v1/CommandLineInterface.java @@ -1,11 +1,12 @@ -package com.mindee; +package com.mindee.v1; +import com.mindee.MindeeException; import com.mindee.input.LocalInputSource; import com.mindee.input.PageOptions; import com.mindee.input.PageOptionsOperation; -import com.mindee.v1.MindeeClient; import com.mindee.v1.cli.CommandLineInterfaceProducts; import com.mindee.v1.cli.ProductProcessor; +import com.mindee.v1.clientOptions.PollingOptions; import com.mindee.v1.clientOptions.PredictOptions; import com.mindee.v1.http.Endpoint; import com.mindee.v1.parsing.common.AsyncPredictResponse; @@ -205,7 +206,7 @@ void generatedMethod( new LocalInputSource(file), PredictOptions.builder().build(), getDefaultPageOptions(), - AsyncPollingOptions.builder().build() + PollingOptions.builder().build() ); System.out.println(document.toString()); } else { diff --git a/src/main/java/com/mindee/v1/MindeeClient.java b/src/main/java/com/mindee/v1/MindeeClient.java index f9c3ea5b3..ce949cf69 100644 --- a/src/main/java/com/mindee/v1/MindeeClient.java +++ b/src/main/java/com/mindee/v1/MindeeClient.java @@ -1,6 +1,5 @@ package com.mindee.v1; -import com.mindee.AsyncPollingOptions; import com.mindee.MindeeException; import com.mindee.input.InputSourceUtils; import com.mindee.input.LocalInputSource; @@ -8,6 +7,7 @@ import com.mindee.pdf.PdfBoxApi; import com.mindee.pdf.PdfOperation; import com.mindee.pdf.SplitQuery; +import com.mindee.v1.clientOptions.PollingOptions; import com.mindee.v1.clientOptions.PredictOptions; import com.mindee.v1.clientOptions.WorkflowOptions; import com.mindee.v1.http.Endpoint; @@ -287,7 +287,7 @@ public AsyncPredictResponse enqueueAndParse( public AsyncPredictResponse enqueueAndParse( Class type, LocalInputSource localInputSource, - AsyncPollingOptions pollingOptions + PollingOptions pollingOptions ) throws IOException, InterruptedException { return this .enqueueAndParse( @@ -319,7 +319,7 @@ public AsyncPredictResponse enqueueAndParse( LocalInputSource localInputSource, PredictOptions predictOptions, PageOptions pageOptions, - AsyncPollingOptions pollingOptions + PollingOptions pollingOptions ) throws IOException, InterruptedException { return this .enqueueAndParse( @@ -349,7 +349,7 @@ public AsyncPredictResponse enqueueAndParse( Class type, LocalInputSource localInputSource, PredictOptions predictOptions, - AsyncPollingOptions pollingOptions + PollingOptions pollingOptions ) throws IOException, InterruptedException { return this .enqueueAndParse( @@ -415,7 +415,7 @@ public AsyncPredictResponse enqueueAndParse( * @param pollingOptions Options for async call parameters * @throws MindeeException Throws if settings aren't set properly. */ - private void validateAsyncParams(AsyncPollingOptions pollingOptions) { + private void validateAsyncParams(PollingOptions pollingOptions) { Double minimumInitialDelaySec = 1.0; Double minimumIntervalSec = 1.0; Integer minimumRetry = 2; @@ -440,14 +440,14 @@ private void validateAsyncParams(AsyncPollingOptions pollingOptions) { private AsyncPredictResponse enqueueAndParse( Class type, Endpoint endpoint, - AsyncPollingOptions pollingOptions, + PollingOptions pollingOptions, byte[] file, String filename, PredictOptions predictOptions, URL urlInputSource ) throws IOException, InterruptedException { if (pollingOptions == null) { - pollingOptions = AsyncPollingOptions.builder().build(); + pollingOptions = PollingOptions.builder().build(); } this.validateAsyncParams(pollingOptions); final int initialDelaySec = (int) (pollingOptions.getInitialDelaySec() * 1000); @@ -832,7 +832,7 @@ public AsyncPredictResponse enqueueAndParse( Class type, Endpoint endpoint, LocalInputSource localInputSource, - AsyncPollingOptions pollingOptions + PollingOptions pollingOptions ) throws IOException, InterruptedException { return this .enqueueAndParse( @@ -866,7 +866,7 @@ public AsyncPredictResponse enqueueAndParse( LocalInputSource localInputSource, PredictOptions predictOptions, PageOptions pageOptions, - AsyncPollingOptions pollingOptions + PollingOptions pollingOptions ) throws IOException, InterruptedException { return this .enqueueAndParse( diff --git a/src/main/java/com/mindee/v1/clientOptions/PollingOptions.java b/src/main/java/com/mindee/v1/clientOptions/PollingOptions.java new file mode 100644 index 000000000..b1b8d4fc5 --- /dev/null +++ b/src/main/java/com/mindee/v1/clientOptions/PollingOptions.java @@ -0,0 +1,12 @@ +package com.mindee.v1.clientOptions; + +import com.mindee.clientOptions.BasePollingOptions; +import lombok.Builder; + +public class PollingOptions extends BasePollingOptions { + + @Builder + public PollingOptions(Double initialDelaySec, Double intervalSec, Integer maxRetries) { + super(initialDelaySec, intervalSec, maxRetries, 2.0, 1.5, 80, 1.0, 1.0, 2); + } +} diff --git a/src/main/java/com/mindee/v2/MindeeClient.java b/src/main/java/com/mindee/v2/MindeeClient.java index be9a1a94f..f9e5ea184 100644 --- a/src/main/java/com/mindee/v2/MindeeClient.java +++ b/src/main/java/com/mindee/v2/MindeeClient.java @@ -3,6 +3,7 @@ import com.mindee.input.LocalInputSource; import com.mindee.input.URLInputSource; import com.mindee.v2.clientOptions.BaseParameters; +import com.mindee.v2.clientOptions.PollingOptions; import com.mindee.v2.http.MindeeApiV2; import com.mindee.v2.http.MindeeHttpApiV2; import com.mindee.v2.http.MindeeHttpExceptionV2; @@ -83,9 +84,10 @@ public TResponse getResult( /** * Send a local file to an async queue, poll, and parse when complete. + * Use default polling options. * * @param inputSource The local input source to send. - * @param params The parameters to send along with the file. + * @param params The product parameters to send along with the file. * @return an instance of {@link ExtractionResponse}. * @throws IOException Throws if the file can't be accessed. * @throws InterruptedException Throws if the thread is interrupted. @@ -95,16 +97,41 @@ public TResponse enqueueAndGetResult( LocalInputSource inputSource, BaseParameters params ) throws IOException, InterruptedException { - params.validatePollingOptions(); + return enqueueAndGetResult( + responseClass, + inputSource, + params, + PollingOptions.builder().build() + ); + } + + /** + * Send a local file to an async queue, poll, and parse when complete. + * Specify polling options. + * + * @param inputSource The local input source to send. + * @param params The product parameters to send along with the file. + * @param pollingOptions The polling options to use. + * @return an instance of {@link ExtractionResponse}. + * @throws IOException Throws if the file can't be accessed. + * @throws InterruptedException Throws if the thread is interrupted. + */ + public TResponse enqueueAndGetResult( + Class responseClass, + LocalInputSource inputSource, + BaseParameters params, + PollingOptions pollingOptions + ) throws IOException, InterruptedException { JobResponse job = enqueue(inputSource, params); - return pollAndFetch(responseClass, job, params); + return pollAndFetch(responseClass, job, pollingOptions); } /** * Send a remote file to an async queue, poll, and parse when complete. + * Use default polling options. * * @param inputSource The URL input source to send. - * @param params The parameters to send along with the file. + * @param params The product parameters to send along with the file. * @return an instance of {@link ExtractionResponse}. * @throws IOException Throws if the file can't be accessed. * @throws InterruptedException Throws if the thread is interrupted. @@ -114,9 +141,29 @@ public TResponse enqueueAndGetResult( URLInputSource inputSource, BaseParameters params ) throws IOException, InterruptedException { - params.validatePollingOptions(); JobResponse job = enqueue(inputSource, params); - return pollAndFetch(responseClass, job, params); + return pollAndFetch(responseClass, job, PollingOptions.builder().build()); + } + + /** + * Send a remote file to an async queue, poll, and parse when complete. + * Specify polling options. + * + * @param inputSource The URL input source to send. + * @param params The product parameters to send along with the file. + * @param pollingOptions The polling options to use. + * @return an instance of {@link ExtractionResponse}. + * @throws IOException Throws if the file can't be accessed. + * @throws InterruptedException Throws if the thread is interrupted. + */ + public TResponse enqueueAndGetResult( + Class responseClass, + URLInputSource inputSource, + BaseParameters params, + PollingOptions pollingOptions + ) throws IOException, InterruptedException { + JobResponse job = enqueue(inputSource, params); + return pollAndFetch(responseClass, job, pollingOptions); } /** @@ -129,16 +176,16 @@ public TResponse enqueueAndGetResult( private TResponse pollAndFetch( Class responseClass, JobResponse initialJob, - BaseParameters options + PollingOptions pollingOptions ) throws InterruptedException { - Thread.sleep((long) (options.getPollingOptions().getInitialDelaySec() * 1000)); + Thread.sleep((long) (pollingOptions.getInitialDelaySec() * 1000)); JobResponse resp = initialJob; int attempts = 0; - int max = options.getPollingOptions().getMaxRetries(); + int max = pollingOptions.getMaxRetries(); while (attempts < max) { - Thread.sleep((long) (options.getPollingOptions().getIntervalSec() * 1000)); + Thread.sleep((long) (pollingOptions.getIntervalSec() * 1000)); resp = getJob(initialJob.getJob().getId()); if (resp.getJob().getStatus().equals("Failed")) { diff --git a/src/main/java/com/mindee/v2/clientOptions/BaseParameters.java b/src/main/java/com/mindee/v2/clientOptions/BaseParameters.java index 7d38c309f..e5f2421bb 100644 --- a/src/main/java/com/mindee/v2/clientOptions/BaseParameters.java +++ b/src/main/java/com/mindee/v2/clientOptions/BaseParameters.java @@ -1,6 +1,5 @@ package com.mindee.v2.clientOptions; -import com.mindee.AsyncPollingOptions; import java.util.Objects; import lombok.Data; import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; @@ -20,10 +19,6 @@ public abstract class BaseParameters { * If empty, no webhooks will be used. */ protected final String[] webhookIds; - /** - * Polling options. Set only if having timeout issues. - */ - protected final AsyncPollingOptions pollingOptions; public MultipartEntityBuilder buildHttpBody(MultipartEntityBuilder builder) { builder.addTextBody("model_id", this.getModelId()); @@ -36,23 +31,10 @@ public MultipartEntityBuilder buildHttpBody(MultipartEntityBuilder builder) { return builder; } - public void validatePollingOptions() { - if (pollingOptions.getInitialDelaySec() < 1) { - throw new IllegalArgumentException("Initial delay must be ≥ 1 s"); - } - if (pollingOptions.getIntervalSec() < 1) { - throw new IllegalArgumentException("Interval must be ≥ 1 s"); - } - if (pollingOptions.getMaxRetries() < 2) { - throw new IllegalArgumentException("Max retries must be ≥ 2"); - } - } - protected static abstract class BaseBuilder> { protected final String modelId; protected String alias; protected String[] webhookIds = new String[] {}; - protected AsyncPollingOptions pollingOptions = AsyncPollingOptions.builder().build(); @SuppressWarnings("unchecked") protected T self() { @@ -74,12 +56,6 @@ public T webhookIds(String[] webhookIds) { this.webhookIds = webhookIds; return self(); } - - /** Set polling options. */ - public T pollingOptions(AsyncPollingOptions pollingOptions) { - this.pollingOptions = pollingOptions; - return self(); - } } } diff --git a/src/main/java/com/mindee/v2/clientOptions/PollingOptions.java b/src/main/java/com/mindee/v2/clientOptions/PollingOptions.java new file mode 100644 index 000000000..95f0a23fd --- /dev/null +++ b/src/main/java/com/mindee/v2/clientOptions/PollingOptions.java @@ -0,0 +1,11 @@ +package com.mindee.v2.clientOptions; + +import com.mindee.clientOptions.BasePollingOptions; +import lombok.Builder; + +public class PollingOptions extends BasePollingOptions { + @Builder + public PollingOptions(Double initialDelaySec, Double intervalSec, Integer maxRetries) { + super(initialDelaySec, intervalSec, maxRetries, 3.0, 1.5, 100, 1.0, 1.0, 2); + } +} diff --git a/src/main/java/com/mindee/v2/product/classification/params/ClassificationParameters.java b/src/main/java/com/mindee/v2/product/classification/params/ClassificationParameters.java index 7fa37267e..d3d29144f 100644 --- a/src/main/java/com/mindee/v2/product/classification/params/ClassificationParameters.java +++ b/src/main/java/com/mindee/v2/product/classification/params/ClassificationParameters.java @@ -1,18 +1,12 @@ package com.mindee.v2.product.classification.params; -import com.mindee.AsyncPollingOptions; import com.mindee.v2.clientOptions.BaseParameters; import com.mindee.v2.http.ProductInfo; @ProductInfo(slug = "classification") public class ClassificationParameters extends BaseParameters { - public ClassificationParameters( - String modelId, - String alias, - String[] webhookIds, - AsyncPollingOptions pollingOptions - ) { - super(modelId, alias, webhookIds, pollingOptions); + public ClassificationParameters(String modelId, String alias, String[] webhookIds) { + super(modelId, alias, webhookIds); } /** @@ -33,7 +27,7 @@ public static final class Builder extends BaseParameters.BaseBuilder { /** Build an immutable {@link ClassificationParameters} instance. */ public ClassificationParameters build() { - return new ClassificationParameters(modelId, alias, webhookIds, pollingOptions); + return new ClassificationParameters(modelId, alias, webhookIds); } } } diff --git a/src/main/java/com/mindee/v2/product/crop/params/CropParameters.java b/src/main/java/com/mindee/v2/product/crop/params/CropParameters.java index 0daa2c6fe..823606d55 100644 --- a/src/main/java/com/mindee/v2/product/crop/params/CropParameters.java +++ b/src/main/java/com/mindee/v2/product/crop/params/CropParameters.java @@ -1,19 +1,13 @@ package com.mindee.v2.product.crop.params; -import com.mindee.AsyncPollingOptions; import com.mindee.v2.clientOptions.BaseParameters; import com.mindee.v2.http.ProductInfo; @ProductInfo(slug = "crop") public class CropParameters extends BaseParameters { - public CropParameters( - String modelId, - String alias, - String[] webhookIds, - AsyncPollingOptions pollingOptions - ) { - super(modelId, alias, webhookIds, pollingOptions); + public CropParameters(String modelId, String alias, String[] webhookIds) { + super(modelId, alias, webhookIds); } /** @@ -34,7 +28,7 @@ public static final class Builder extends BaseParameters.BaseBuilder { /** Build an immutable {@link CropParameters} instance. */ public CropParameters build() { - return new CropParameters(modelId, alias, webhookIds, pollingOptions); + return new CropParameters(modelId, alias, webhookIds); } } } diff --git a/src/main/java/com/mindee/v2/product/extraction/params/ExtractionParameters.java b/src/main/java/com/mindee/v2/product/extraction/params/ExtractionParameters.java index 077d8f73c..06652899d 100644 --- a/src/main/java/com/mindee/v2/product/extraction/params/ExtractionParameters.java +++ b/src/main/java/com/mindee/v2/product/extraction/params/ExtractionParameters.java @@ -1,6 +1,5 @@ package com.mindee.v2.product.extraction.params; -import com.mindee.AsyncPollingOptions; import com.mindee.v2.clientOptions.BaseParameters; import com.mindee.v2.http.ProductInfo; import lombok.EqualsAndHashCode; @@ -45,7 +44,6 @@ private ExtractionParameters( String modelId, String alias, String[] webhookIds, - AsyncPollingOptions pollingOptions, Boolean rag, Boolean rawText, Boolean polygon, @@ -53,7 +51,7 @@ private ExtractionParameters( String textContext, String dataSchema ) { - super(modelId, alias, webhookIds, pollingOptions); + super(modelId, alias, webhookIds); this.rag = rag; this.rawText = rawText; this.polygon = polygon; @@ -155,7 +153,6 @@ public ExtractionParameters build() { modelId, alias, webhookIds, - pollingOptions, rag, rawText, polygon, diff --git a/src/main/java/com/mindee/v2/product/ocr/params/OcrParameters.java b/src/main/java/com/mindee/v2/product/ocr/params/OcrParameters.java index 0ab4a11a5..74359638b 100644 --- a/src/main/java/com/mindee/v2/product/ocr/params/OcrParameters.java +++ b/src/main/java/com/mindee/v2/product/ocr/params/OcrParameters.java @@ -1,19 +1,13 @@ package com.mindee.v2.product.ocr.params; -import com.mindee.AsyncPollingOptions; import com.mindee.v2.clientOptions.BaseParameters; import com.mindee.v2.http.ProductInfo; @ProductInfo(slug = "ocr") public class OcrParameters extends BaseParameters { - public OcrParameters( - String modelId, - String alias, - String[] webhookIds, - AsyncPollingOptions pollingOptions - ) { - super(modelId, alias, webhookIds, pollingOptions); + public OcrParameters(String modelId, String alias, String[] webhookIds) { + super(modelId, alias, webhookIds); } /** @@ -34,7 +28,7 @@ public static final class Builder extends BaseParameters.BaseBuilder { /** Build an immutable {@link OcrParameters} instance. */ public OcrParameters build() { - return new OcrParameters(modelId, alias, webhookIds, pollingOptions); + return new OcrParameters(modelId, alias, webhookIds); } } } diff --git a/src/main/java/com/mindee/v2/product/split/params/SplitParameters.java b/src/main/java/com/mindee/v2/product/split/params/SplitParameters.java index 4624b3177..a1aab32b3 100644 --- a/src/main/java/com/mindee/v2/product/split/params/SplitParameters.java +++ b/src/main/java/com/mindee/v2/product/split/params/SplitParameters.java @@ -1,19 +1,13 @@ package com.mindee.v2.product.split.params; -import com.mindee.AsyncPollingOptions; import com.mindee.v2.clientOptions.BaseParameters; import com.mindee.v2.http.ProductInfo; @ProductInfo(slug = "split") public class SplitParameters extends BaseParameters { - public SplitParameters( - String modelId, - String alias, - String[] webhookIds, - AsyncPollingOptions pollingOptions - ) { - super(modelId, alias, webhookIds, pollingOptions); + public SplitParameters(String modelId, String alias, String[] webhookIds) { + super(modelId, alias, webhookIds); } /** @@ -34,7 +28,7 @@ public static final class Builder extends BaseParameters.BaseBuilder { /** Build an immutable {@link SplitParameters} instance. */ public SplitParameters build() { - return new SplitParameters(modelId, alias, webhookIds, pollingOptions); + return new SplitParameters(modelId, alias, webhookIds); } } } diff --git a/src/test/java/com/mindee/v2/MindeeClientIT.java b/src/test/java/com/mindee/v2/MindeeClientIT.java index d8ca1d942..9e6998f41 100644 --- a/src/test/java/com/mindee/v2/MindeeClientIT.java +++ b/src/test/java/com/mindee/v2/MindeeClientIT.java @@ -4,9 +4,9 @@ import static com.mindee.TestingUtilities.getV2ResourcePath; import static org.junit.jupiter.api.Assertions.*; -import com.mindee.AsyncPollingOptions; import com.mindee.input.LocalInputSource; import com.mindee.input.URLInputSource; +import com.mindee.v2.clientOptions.PollingOptions; import com.mindee.v2.http.MindeeHttpExceptionV2; import com.mindee.v2.product.extraction.ExtractionInference; import com.mindee.v2.product.extraction.ExtractionResponse; @@ -42,12 +42,17 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep .confidence(null) .alias("java-integration-test_multipage") .textContext(null) - .pollingOptions( - AsyncPollingOptions.builder().initialDelaySec(3.0).intervalSec(1.5).maxRetries(80).build() - ) .build(); - var response = mindeeClient.enqueueAndGetResult(ExtractionResponse.class, source, params); + var pollingOptions = PollingOptions + .builder() + .initialDelaySec(3.0) + .intervalSec(1.5) + .maxRetries(80) + .build(); + + var response = mindeeClient + .enqueueAndGetResult(ExtractionResponse.class, source, params, pollingOptions); assertNotNull(response); var inference = response.getInference(); diff --git a/src/test/java/com/mindee/v2/clientOptions/PollingOptionsTest.java b/src/test/java/com/mindee/v2/clientOptions/PollingOptionsTest.java new file mode 100644 index 000000000..e0d646c46 --- /dev/null +++ b/src/test/java/com/mindee/v2/clientOptions/PollingOptionsTest.java @@ -0,0 +1,40 @@ +package com.mindee.v2.clientOptions; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class PollingOptionsTest { + + @Test + void shouldSetDefaultValues() { + PollingOptions pollingOptions = PollingOptions.builder().build(); + + Assertions.assertEquals(3.0, pollingOptions.getInitialDelaySec()); + Assertions.assertEquals(1.5, pollingOptions.getIntervalSec()); + Assertions.assertEquals(100, pollingOptions.getMaxRetries()); + } + + @Test + void shouldSetCustomValues() { + PollingOptions pollingOptions = PollingOptions + .builder() + .initialDelaySec(4.0) + .intervalSec(2.5) + .maxRetries(50) + .build(); + + Assertions.assertEquals(4.0, pollingOptions.getInitialDelaySec()); + Assertions.assertEquals(2.5, pollingOptions.getIntervalSec()); + Assertions.assertEquals(50, pollingOptions.getMaxRetries()); + } + + @Test + void shouldThrowWhenInitialDelayIsTooLow() { + IllegalArgumentException exception = Assertions + .assertThrows( + IllegalArgumentException.class, + () -> PollingOptions.builder().initialDelaySec(0.1).build() + ); + Assertions.assertEquals("Initial delay must be ≥ 1.0", exception.getMessage()); + } +} diff --git a/src/test/java/com/mindee/v2/product/CropIT.java b/src/test/java/com/mindee/v2/product/CropIT.java index 336dabe22..c99cd124d 100644 --- a/src/test/java/com/mindee/v2/product/CropIT.java +++ b/src/test/java/com/mindee/v2/product/CropIT.java @@ -3,9 +3,9 @@ import static com.mindee.TestingUtilities.getResourcePath; import static org.junit.jupiter.api.Assertions.*; -import com.mindee.AsyncPollingOptions; import com.mindee.input.LocalInputSource; import com.mindee.v2.MindeeClient; +import com.mindee.v2.clientOptions.PollingOptions; import com.mindee.v2.product.crop.CropResponse; import com.mindee.v2.product.crop.params.CropParameters; import java.io.IOException; @@ -34,15 +34,19 @@ void setUp() { @DisplayName("Empty, multi-page PDF – enqueue & parse must succeed") void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedException { var source = new LocalInputSource(getResourcePath("file_types/pdf/multipage_cut-2.pdf")); - CropParameters params = CropParameters + var params = CropParameters .builder(modelId) .alias("java_integration-test_crop_multipage") - .pollingOptions( - AsyncPollingOptions.builder().initialDelaySec(3.0).intervalSec(1.5).maxRetries(80).build() - ) + .build(); + var pollingOptions = PollingOptions + .builder() + .initialDelaySec(3.0) + .intervalSec(1.5) + .maxRetries(80) .build(); - CropResponse response = mindeeClient.enqueueAndGetResult(CropResponse.class, source, params); + CropResponse response = mindeeClient + .enqueueAndGetResult(CropResponse.class, source, params, pollingOptions); assertNotNull(response); var inference = response.getInference(); diff --git a/src/test/java/com/mindee/v2/product/SplitIT.java b/src/test/java/com/mindee/v2/product/SplitIT.java index 6419c0bac..967b71c10 100644 --- a/src/test/java/com/mindee/v2/product/SplitIT.java +++ b/src/test/java/com/mindee/v2/product/SplitIT.java @@ -5,9 +5,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.mindee.AsyncPollingOptions; import com.mindee.input.LocalInputSource; import com.mindee.v2.MindeeClient; +import com.mindee.v2.clientOptions.PollingOptions; import com.mindee.v2.product.split.SplitResponse; import com.mindee.v2.product.split.params.SplitParameters; import java.io.IOException; @@ -39,12 +39,16 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep var params = SplitParameters .builder(modelId) .alias("java_integration-test_split_multipage") - .pollingOptions( - AsyncPollingOptions.builder().initialDelaySec(3.0).intervalSec(1.5).maxRetries(80).build() - ) + .build(); + var pollingOptions = PollingOptions + .builder() + .initialDelaySec(3.0) + .intervalSec(1.5) + .maxRetries(80) .build(); - var response = mindeeClient.enqueueAndGetResult(SplitResponse.class, source, params); + var response = mindeeClient + .enqueueAndGetResult(SplitResponse.class, source, params, pollingOptions); assertNotNull(response); var inference = response.getInference(); From a7c17f0c72ba38c333e411fd3903bad62979a533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Fri, 10 Apr 2026 17:27:57 +0200 Subject: [PATCH 9/9] :recycle: use 'var' to simplify imports (#314) --- docs/code_samples/bank_account_details_v2.txt | 4 +- docs/code_samples/barcode_reader_v1.txt | 4 +- docs/code_samples/carte_grise_v1.txt | 4 +- docs/code_samples/cropper_v1.txt | 4 +- docs/code_samples/default.txt | 4 +- docs/code_samples/default_async.txt | 4 +- docs/code_samples/driver_license_v1_async.txt | 4 +- docs/code_samples/expense_receipts_v5.txt | 4 +- .../expense_receipts_v5_async.txt | 4 +- docs/code_samples/financial_document_v1.txt | 4 +- .../financial_document_v1_async.txt | 4 +- docs/code_samples/idcard_fr_v1.txt | 4 +- docs/code_samples/idcard_fr_v2.txt | 4 +- docs/code_samples/ind_passport_v1_async.txt | 4 +- .../international_id_v2_async.txt | 4 +- .../invoice_splitter_v1_async.txt | 4 +- docs/code_samples/invoices_v4.txt | 4 +- docs/code_samples/invoices_v4_async.txt | 4 +- .../multi_receipts_detector_v1.txt | 4 +- docs/code_samples/passport_v1.txt | 4 +- docs/code_samples/v2_classification.txt | 12 ++-- docs/code_samples/v2_crop.txt | 9 ++- docs/code_samples/v2_extraction.txt | 9 ++- docs/code_samples/v2_ocr.txt | 9 ++- docs/code_samples/v2_split.txt | 9 ++- docs/code_samples/workflow_execution.txt | 4 +- .../AutoInvoiceSplitterExtractionExample.java | 4 +- .../AutoMultiReceiptExtractionExample.java | 4 +- .../com/mindee/image/ImageCompressor.java | 6 +- .../java/com/mindee/image/ImageExtractor.java | 5 +- .../com/mindee/v1/CommandLineInterface.java | 10 +-- .../java/com/mindee/v2/http/MindeeApiV2.java | 4 +- .../com/mindee/v2/http/MindeeHttpApiV2.java | 61 +++++++++---------- .../com/mindee/v2/parsing/BaseInference.java | 4 +- .../inference/DataSchemaActiveOptions.java | 2 +- .../inference/InferenceActiveOptions.java | 2 +- .../v2/parsing/inference/InferenceFile.java | 2 +- .../v2/parsing/inference/InferenceJob.java | 2 +- .../v2/parsing/inference/InferenceModel.java | 2 +- .../mindee/v2/parsing/inference/RawText.java | 2 +- .../inference/field/InferenceFields.java | 2 +- .../v2/parsing/inference/field/ListField.java | 2 +- .../classification/ClassificationResult.java | 2 +- .../mindee/v2/product/crop/CropResult.java | 2 +- .../extraction/ExtractionInference.java | 2 +- .../product/extraction/ExtractionResult.java | 2 +- .../com/mindee/v2/product/ocr/OcrResult.java | 2 +- .../mindee/v2/product/split/SplitResult.java | 2 +- .../com/mindee/v1/workflow/WorkflowTest.java | 4 +- .../java/com/mindee/v2/MindeeClientTest.java | 4 +- 50 files changed, 127 insertions(+), 139 deletions(-) diff --git a/docs/code_samples/bank_account_details_v2.txt b/docs/code_samples/bank_account_details_v2.txt index 6e0682333..175bb9054 100644 --- a/docs/code_samples/bank_account_details_v2.txt +++ b/docs/code_samples/bank_account_details_v2.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/barcode_reader_v1.txt b/docs/code_samples/barcode_reader_v1.txt index b44cbacfa..676358a66 100644 --- a/docs/code_samples/barcode_reader_v1.txt +++ b/docs/code_samples/barcode_reader_v1.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/carte_grise_v1.txt b/docs/code_samples/carte_grise_v1.txt index fabb8ae1d..b619f3d63 100644 --- a/docs/code_samples/carte_grise_v1.txt +++ b/docs/code_samples/carte_grise_v1.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/cropper_v1.txt b/docs/code_samples/cropper_v1.txt index 906d1af16..6d2f40d5a 100644 --- a/docs/code_samples/cropper_v1.txt +++ b/docs/code_samples/cropper_v1.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/default.txt b/docs/code_samples/default.txt index 5ff7a6452..f40009473 100644 --- a/docs/code_samples/default.txt +++ b/docs/code_samples/default.txt @@ -13,10 +13,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); // Configure the endpoint Endpoint endpoint = new Endpoint( diff --git a/docs/code_samples/default_async.txt b/docs/code_samples/default_async.txt index 735c0e02d..c7c55aed4 100644 --- a/docs/code_samples/default_async.txt +++ b/docs/code_samples/default_async.txt @@ -13,10 +13,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); // Configure the endpoint Endpoint endpoint = new Endpoint( diff --git a/docs/code_samples/driver_license_v1_async.txt b/docs/code_samples/driver_license_v1_async.txt index ff8114bb3..5c3e32679 100644 --- a/docs/code_samples/driver_license_v1_async.txt +++ b/docs/code_samples/driver_license_v1_async.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); // Parse the file asynchronously AsyncPredictResponse response = mindeeClient.enqueueAndParse( diff --git a/docs/code_samples/expense_receipts_v5.txt b/docs/code_samples/expense_receipts_v5.txt index 21a66f4f7..683f29dee 100644 --- a/docs/code_samples/expense_receipts_v5.txt +++ b/docs/code_samples/expense_receipts_v5.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/expense_receipts_v5_async.txt b/docs/code_samples/expense_receipts_v5_async.txt index b2e797982..fb2d274ca 100644 --- a/docs/code_samples/expense_receipts_v5_async.txt +++ b/docs/code_samples/expense_receipts_v5_async.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); // Parse the file asynchronously AsyncPredictResponse response = mindeeClient.enqueueAndParse( diff --git a/docs/code_samples/financial_document_v1.txt b/docs/code_samples/financial_document_v1.txt index 73fda927b..bef3d69bf 100644 --- a/docs/code_samples/financial_document_v1.txt +++ b/docs/code_samples/financial_document_v1.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/financial_document_v1_async.txt b/docs/code_samples/financial_document_v1_async.txt index 1370a6416..bb06eed21 100644 --- a/docs/code_samples/financial_document_v1_async.txt +++ b/docs/code_samples/financial_document_v1_async.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); // Parse the file asynchronously AsyncPredictResponse response = mindeeClient.enqueueAndParse( diff --git a/docs/code_samples/idcard_fr_v1.txt b/docs/code_samples/idcard_fr_v1.txt index 7e531ecd7..3ce921ac1 100644 --- a/docs/code_samples/idcard_fr_v1.txt +++ b/docs/code_samples/idcard_fr_v1.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/idcard_fr_v2.txt b/docs/code_samples/idcard_fr_v2.txt index 88d22f1b1..bb2e409a0 100644 --- a/docs/code_samples/idcard_fr_v2.txt +++ b/docs/code_samples/idcard_fr_v2.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/ind_passport_v1_async.txt b/docs/code_samples/ind_passport_v1_async.txt index b64965cda..6fa8d2157 100644 --- a/docs/code_samples/ind_passport_v1_async.txt +++ b/docs/code_samples/ind_passport_v1_async.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); // Parse the file asynchronously AsyncPredictResponse response = mindeeClient.enqueueAndParse( diff --git a/docs/code_samples/international_id_v2_async.txt b/docs/code_samples/international_id_v2_async.txt index 3b6956c4f..458396fcc 100644 --- a/docs/code_samples/international_id_v2_async.txt +++ b/docs/code_samples/international_id_v2_async.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); // Parse the file asynchronously AsyncPredictResponse response = mindeeClient.enqueueAndParse( diff --git a/docs/code_samples/invoice_splitter_v1_async.txt b/docs/code_samples/invoice_splitter_v1_async.txt index ccbf64cf4..e766d43bc 100644 --- a/docs/code_samples/invoice_splitter_v1_async.txt +++ b/docs/code_samples/invoice_splitter_v1_async.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); // Parse the file asynchronously AsyncPredictResponse response = mindeeClient.enqueueAndParse( diff --git a/docs/code_samples/invoices_v4.txt b/docs/code_samples/invoices_v4.txt index 5d666e865..9c1491bd2 100644 --- a/docs/code_samples/invoices_v4.txt +++ b/docs/code_samples/invoices_v4.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/invoices_v4_async.txt b/docs/code_samples/invoices_v4_async.txt index ac52fd1be..5b906e05c 100644 --- a/docs/code_samples/invoices_v4_async.txt +++ b/docs/code_samples/invoices_v4_async.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); // Parse the file asynchronously AsyncPredictResponse response = mindeeClient.enqueueAndParse( diff --git a/docs/code_samples/multi_receipts_detector_v1.txt b/docs/code_samples/multi_receipts_detector_v1.txt index ec02e88e2..b1de23b3c 100644 --- a/docs/code_samples/multi_receipts_detector_v1.txt +++ b/docs/code_samples/multi_receipts_detector_v1.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/passport_v1.txt b/docs/code_samples/passport_v1.txt index 9ae473641..bb1491080 100644 --- a/docs/code_samples/passport_v1.txt +++ b/docs/code_samples/passport_v1.txt @@ -12,10 +12,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Parse the file PredictResponse response = mindeeClient.parse( diff --git a/docs/code_samples/v2_classification.txt b/docs/code_samples/v2_classification.txt index f958f86e8..bc6b981a1 100644 --- a/docs/code_samples/v2_classification.txt +++ b/docs/code_samples/v2_classification.txt @@ -1,8 +1,6 @@ import com.mindee.input.LocalInputSource; import com.mindee.v2.MindeeClient; -import com.mindee.v2.product.classification.ClassificationClassifier; import com.mindee.v2.product.classification.ClassificationResponse; -import com.mindee.v2.product.classification.ClassificationResult; import com.mindee.v2.product.classification.params.ClassificationParameters; import java.io.IOException; @@ -16,17 +14,17 @@ public class SimpleMindeeClientV2 { String modelId = "MY_MODEL_ID"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Set inference parameters // Note: modelId is mandatory. - ClassificationParameters classificationParams = ClassificationParameters + var classificationParams = ClassificationParameters // ID of the model, required. .builder(modelId) .build(); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Send for processing using polling ClassificationResponse response = mindeeClient.enqueueAndGetResult( @@ -39,7 +37,7 @@ public class SimpleMindeeClientV2 { System.out.println(response.getInference().toString()); // Access the classification result - ClassificationResult result = response.getInference().getResult(); - ClassificationClassifier classification = result.getClassification(); + var result = response.getInference().getResult(); + var classification = result.getClassification(); } } diff --git a/docs/code_samples/v2_crop.txt b/docs/code_samples/v2_crop.txt index b7a9af692..436894376 100644 --- a/docs/code_samples/v2_crop.txt +++ b/docs/code_samples/v2_crop.txt @@ -1,7 +1,6 @@ import com.mindee.input.LocalInputSource; import com.mindee.v2.MindeeClient; import com.mindee.v2.product.crop.CropResponse; -import com.mindee.v2.product.crop.CropResult; import com.mindee.v2.product.crop.params.CropParameters; import java.io.IOException; @@ -15,16 +14,16 @@ public class SimpleMindeeClientV2 { String modelId = "MY_MODEL_ID"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Set inference parameters - CropParameters cropParams = CropParameters + var cropParams = CropParameters // ID of the model, required. .builder(modelId) .build(); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Send for processing using polling CropResponse response = mindeeClient.enqueueAndGetResult( @@ -37,6 +36,6 @@ public class SimpleMindeeClientV2 { System.out.println(response.getInference().toString()); // Access the crop results - CropResult result = response.getInference().getResult(); + var result = response.getInference().getResult(); } } diff --git a/docs/code_samples/v2_extraction.txt b/docs/code_samples/v2_extraction.txt index bcfba5ed9..1660c75f1 100644 --- a/docs/code_samples/v2_extraction.txt +++ b/docs/code_samples/v2_extraction.txt @@ -2,7 +2,6 @@ import com.mindee.input.LocalInputSource; import com.mindee.v2.MindeeClient; import com.mindee.v2.product.extraction.params.ExtractionParameters; import com.mindee.v2.product.extraction.ExtractionResponse; -import com.mindee.v2.parsing.inference.field.InferenceFields; import java.io.IOException; public class SimpleMindeeClientV2 { @@ -15,10 +14,10 @@ public class SimpleMindeeClientV2 { String modelId = "MY_MODEL_ID"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Set inference parameters - ExtractionParameters extractionParams = ExtractionParameters + var extractionParams = ExtractionParameters // ID of the model, required. .builder(modelId) @@ -37,7 +36,7 @@ public class SimpleMindeeClientV2 { .build(); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Send for processing using polling ExtractionResponse response = mindeeClient.enqueueAndGetResult( @@ -50,6 +49,6 @@ public class SimpleMindeeClientV2 { System.out.println(response.getInference().toString()); // Access the result fields - InferenceFields fields = response.getInference().getResult().getFields(); + var fields = response.getInference().getResult().getFields(); } } diff --git a/docs/code_samples/v2_ocr.txt b/docs/code_samples/v2_ocr.txt index 2401b2ddf..56729b69f 100644 --- a/docs/code_samples/v2_ocr.txt +++ b/docs/code_samples/v2_ocr.txt @@ -1,7 +1,6 @@ import com.mindee.input.LocalInputSource; import com.mindee.v2.MindeeClient; import com.mindee.v2.product.ocr.OcrResponse; -import com.mindee.v2.product.ocr.OcrResult; import com.mindee.v2.product.ocr.params.OcrParameters; import java.io.IOException; @@ -15,16 +14,16 @@ public class SimpleMindeeClientV2 { String modelId = "MY_MODEL_ID"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Set inference parameters - OcrParameters ocrParams = OcrParameters + var ocrParams = OcrParameters // ID of the model, required. .builder(modelId) .build(); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Send for processing using polling OcrResponse response = mindeeClient.enqueueAndGetResult( @@ -37,6 +36,6 @@ public class SimpleMindeeClientV2 { System.out.println(response.getInference().toString()); // Access the result OCR pages - OcrResult result = response.getInference().getResult(); + var result = response.getInference().getResult(); } } diff --git a/docs/code_samples/v2_split.txt b/docs/code_samples/v2_split.txt index a6acd3d29..7665b3dca 100644 --- a/docs/code_samples/v2_split.txt +++ b/docs/code_samples/v2_split.txt @@ -1,7 +1,6 @@ import com.mindee.input.LocalInputSource; import com.mindee.v2.MindeeClient; import com.mindee.v2.product.split.SplitResponse; -import com.mindee.v2.product.split.SplitResult; import com.mindee.v2.product.split.params.SplitParameters; import java.io.IOException; @@ -15,16 +14,16 @@ public class SimpleMindeeClientV2 { String modelId = "MY_MODEL_ID"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Set inference parameters - SplitParameters splitParams = SplitParameters + var splitParams = SplitParameters // ID of the model, required. .builder(modelId) .build(); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Send for processing using polling SplitResponse response = mindeeClient.enqueueAndGetResult( @@ -37,6 +36,6 @@ public class SimpleMindeeClientV2 { System.out.println(response.getInference().toString()); // Access the split result - SplitResult result = response.getInference().getResult(); + var result = response.getInference().getResult(); } } diff --git a/docs/code_samples/workflow_execution.txt b/docs/code_samples/workflow_execution.txt index 2f2dce7b0..719989855 100644 --- a/docs/code_samples/workflow_execution.txt +++ b/docs/code_samples/workflow_execution.txt @@ -13,10 +13,10 @@ public class SimpleMindeeClientV1 { String filePath = "/path/to/the/file.ext"; // Init a new client - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); // Load a file from disk - LocalInputSource inputSource = new LocalInputSource(filePath); + var inputSource = new LocalInputSource(filePath); // Send the file to a workflow WorkflowResponse response = mindeeClient.executeWorkflow( diff --git a/example/AutoInvoiceSplitterExtractionExample.java b/example/AutoInvoiceSplitterExtractionExample.java index 5b2a0c4ca..2cb78c78f 100644 --- a/example/AutoInvoiceSplitterExtractionExample.java +++ b/example/AutoInvoiceSplitterExtractionExample.java @@ -12,7 +12,7 @@ public class AutoInvoiceSplitterExtractionExample { private static final String API_KEY = "my-api-key"; - private static final MindeeClient mindeeClient = new MindeeClient(API_KEY); + private static final var mindeeClient = new MindeeClient(API_KEY); public static void main(String[] args) throws IOException, InterruptedException { String filePath = "/path/to/the/file.ext"; @@ -20,7 +20,7 @@ public static void main(String[] args) throws IOException, InterruptedException } private static void invoiceSplitterAutoExtraction(String filePath) throws IOException, InterruptedException { - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); if (inputSource.isPdf() && new PDFExtractor(inputSource).getPageCount() > 1) { parseMultiPage(inputSource); diff --git a/example/AutoMultiReceiptExtractionExample.java b/example/AutoMultiReceiptExtractionExample.java index bf3553d4c..2556b7add 100644 --- a/example/AutoMultiReceiptExtractionExample.java +++ b/example/AutoMultiReceiptExtractionExample.java @@ -14,7 +14,7 @@ public class AutoMultiReceiptExtractionExample { private static final String API_KEY = "my-api-key"; - private static final MindeeClient mindeeClient = new MindeeClient(API_KEY); + private static final var mindeeClient = new MindeeClient(API_KEY); public static void main(String[] args) throws IOException, InterruptedException { String myFilePath = "/path/to/the/file.ext"; @@ -22,7 +22,7 @@ public static void main(String[] args) throws IOException, InterruptedException } private static void processMultiReceipts(String filePath) throws IOException, InterruptedException { - LocalInputSource inputSource = new LocalInputSource(new File(filePath)); + var inputSource = new LocalInputSource(new File(filePath)); PredictResponse resultSplit = mindeeClient.parse(MultiReceiptsDetectorV1.class, inputSource); diff --git a/src/main/java/com/mindee/image/ImageCompressor.java b/src/main/java/com/mindee/image/ImageCompressor.java index b56096322..d14a3df78 100644 --- a/src/main/java/com/mindee/image/ImageCompressor.java +++ b/src/main/java/com/mindee/image/ImageCompressor.java @@ -8,7 +8,6 @@ import javax.imageio.IIOImage; import javax.imageio.ImageIO; import javax.imageio.ImageWriteParam; -import javax.imageio.ImageWriter; /** * Image compression class. @@ -38,8 +37,7 @@ public static byte[] compressImage( var bis = new ByteArrayInputStream(imageData); var original = ImageIO.read(bis); - ImageUtils.Dimensions dimensions = ImageUtils - .calculateNewDimensions(original, maxWidth, maxHeight); + var dimensions = ImageUtils.calculateNewDimensions(original, maxWidth, maxHeight); return compressImage(original, quality, dimensions.width, dimensions.height); } @@ -94,7 +92,7 @@ public static byte[] encodeToJpegByteArray( var outputStream = new ByteArrayOutputStream(); var writers = ImageIO.getImageWritersByFormatName("jpg"); - ImageWriter writer = writers.next(); + var writer = writers.next(); var params = writer.getDefaultWriteParam(); params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); diff --git a/src/main/java/com/mindee/image/ImageExtractor.java b/src/main/java/com/mindee/image/ImageExtractor.java index 24ea7b15b..4b62e16ce 100644 --- a/src/main/java/com/mindee/image/ImageExtractor.java +++ b/src/main/java/com/mindee/image/ImageExtractor.java @@ -1,7 +1,6 @@ package com.mindee.image; import com.mindee.geometry.Bbox; -import com.mindee.geometry.Polygon; import com.mindee.geometry.PositionDataField; import com.mindee.input.InputSourceUtils; import com.mindee.input.LocalInputSource; @@ -144,7 +143,7 @@ public ExtractedImage extractImage( ) { String[] splitName = InputSourceUtils.splitNameStrict(filename); String saveFormat = splitName[1].toLowerCase(); - Polygon polygon = field.getPolygon(); + var polygon = field.getPolygon(); if (polygon == null) { return null; } @@ -165,7 +164,7 @@ public ExtractedImage extractImage( * @param Type of field (needs to support positioning data). * @param field The field to extract. * @param index The index to use for naming the extracted image. - * @param pageIndex The page index to extract, begins at 0. + * @param pageIndex The 0-based page index to extract. * @return The {@link ExtractedImage}, or null if the field does not have valid * position data. */ diff --git a/src/main/java/com/mindee/v1/CommandLineInterface.java b/src/main/java/com/mindee/v1/CommandLineInterface.java index 09c6bfa45..1ee63c98a 100644 --- a/src/main/java/com/mindee/v1/CommandLineInterface.java +++ b/src/main/java/com/mindee/v1/CommandLineInterface.java @@ -183,7 +183,7 @@ void generatedMethod( @Parameters(index = "0", scope = ScopeType.LOCAL, paramLabel = "") File file ) throws IOException, InterruptedException { - MindeeClient mindeeClient = new MindeeClient(apiKey); + var mindeeClient = new MindeeClient(apiKey); Endpoint endpoint = new Endpoint(endpointName, accountName, productVersion); @@ -244,8 +244,8 @@ private String wordsOutput(Ocr ocr) { Class productClass, File file ) throws IOException { - MindeeClient mindeeClient = new MindeeClient(apiKey); - LocalInputSource inputSource = new LocalInputSource(file); + var mindeeClient = new MindeeClient(apiKey); + var inputSource = new LocalInputSource(file); PredictResponse response; PredictOptions predictOptions = PredictOptions .builder() @@ -281,8 +281,8 @@ private String wordsOutput(Ocr ocr) { Class productClass, File file ) throws IOException, InterruptedException { - MindeeClient mindeeClient = new MindeeClient(apiKey); - LocalInputSource inputSource = new LocalInputSource(file); + var mindeeClient = new MindeeClient(apiKey); + var inputSource = new LocalInputSource(file); AsyncPredictResponse response; PredictOptions predictOptions = PredictOptions .builder() diff --git a/src/main/java/com/mindee/v2/http/MindeeApiV2.java b/src/main/java/com/mindee/v2/http/MindeeApiV2.java index 197e7b5fd..af79cd998 100644 --- a/src/main/java/com/mindee/v2/http/MindeeApiV2.java +++ b/src/main/java/com/mindee/v2/http/MindeeApiV2.java @@ -67,7 +67,7 @@ protected ErrorResponse makeUnknownError(int statusCode) { } protected ProductInfo getResponseProductInfo(Class responseClass) { - ProductInfo productInfo = responseClass.getAnnotation(ProductInfo.class); + var productInfo = responseClass.getAnnotation(ProductInfo.class); if (productInfo == null) { throw new MindeeException( "The class " + responseClass.getSimpleName() + " is not annotated with @ProductInfo" @@ -77,7 +77,7 @@ protected ProductInfo getResponseProductInfo(Class res } protected ProductInfo getParamsProductInfo(Class responseClass) { - ProductInfo productInfo = responseClass.getAnnotation(ProductInfo.class); + var productInfo = responseClass.getAnnotation(ProductInfo.class); if (productInfo == null) { throw new MindeeException( "The class " + responseClass.getSimpleName() + " is not annotated with @ProductInfo" diff --git a/src/main/java/com/mindee/v2/http/MindeeHttpApiV2.java b/src/main/java/com/mindee/v2/http/MindeeHttpApiV2.java index 0a01686d4..48669a4b1 100644 --- a/src/main/java/com/mindee/v2/http/MindeeHttpApiV2.java +++ b/src/main/java/com/mindee/v2/http/MindeeHttpApiV2.java @@ -19,11 +19,9 @@ import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.entity.mime.HttpMultipartMode; import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; -import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.ContentType; -import org.apache.hc.core5.http.HttpEntity; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.net.URIBuilder; @@ -69,12 +67,12 @@ private MindeeHttpApiV2(MindeeSettings mindeeSettings, HttpClientBuilder httpCli */ @Override public JobResponse reqPostEnqueue(LocalInputSource inputSource, BaseParameters options) { - ProductInfo productInfo = getParamsProductInfo(options.getClass()); - String url = String + var productInfo = getParamsProductInfo(options.getClass()); + var url = String .format("%s/products/%s/enqueue", this.mindeeSettings.getBaseUrl(), productInfo.slug()); - HttpPost post = buildHttpPost(url); + var post = buildHttpPost(url); - MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + var builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.EXTENDED); builder .addBinaryBody( @@ -96,12 +94,12 @@ public JobResponse reqPostEnqueue(LocalInputSource inputSource, BaseParameters o */ @Override public JobResponse reqPostEnqueue(URLInputSource inputSource, BaseParameters options) { - ProductInfo productInfo = getParamsProductInfo(options.getClass()); - String url = String + var productInfo = getParamsProductInfo(options.getClass()); + var url = String .format("%s/products/%s/enqueue", this.mindeeSettings.getBaseUrl(), productInfo.slug()); - HttpPost post = buildHttpPost(url); + var post = buildHttpPost(url); - MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + var builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.EXTENDED); builder.addTextBody("url", inputSource.getUrl()); post.setEntity(options.buildHttpBody(builder).build()); @@ -115,16 +113,15 @@ public JobResponse reqPostEnqueue(URLInputSource inputSource, BaseParameters opt * @return a valid job response. */ private JobResponse executeEnqueue(HttpPost post) { - try (CloseableHttpClient httpClient = httpClientBuilder.build()) { + try (var httpClient = httpClientBuilder.build()) { return httpClient.execute(post, response -> { - HttpEntity responseEntity = response.getEntity(); - int statusCode = response.getCode(); + var responseEntity = response.getEntity(); + var statusCode = response.getCode(); if (isInvalidStatusCode(statusCode)) { throw getHttpError(response); } try { - String raw = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); - + var raw = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); return deserializeOrThrow(raw, JobResponse.class, response.getCode()); } finally { EntityUtils.consumeQuietly(responseEntity); @@ -138,25 +135,25 @@ private JobResponse executeEnqueue(HttpPost post) { @Override public JobResponse reqGetJob(String jobId) { - String url = this.mindeeSettings.getBaseUrl() + "/jobs/" + jobId; - HttpGet get = new HttpGet(url); + var url = this.mindeeSettings.getBaseUrl() + "/jobs/" + jobId; + var get = new HttpGet(url); if (this.mindeeSettings.getApiKey().isPresent()) { get.setHeader(HttpHeaders.AUTHORIZATION, this.mindeeSettings.getApiKey().get()); } get.setHeader(HttpHeaders.USER_AGENT, getUserAgent()); - RequestConfig noRedirect = RequestConfig.custom().setRedirectsEnabled(false).build(); + var noRedirect = RequestConfig.custom().setRedirectsEnabled(false).build(); get.setConfig(noRedirect); - try (CloseableHttpClient httpClient = httpClientBuilder.build()) { + try (var httpClient = httpClientBuilder.build()) { return httpClient.execute(get, response -> { - HttpEntity responseEntity = response.getEntity(); - int statusCode = response.getCode(); + var responseEntity = response.getEntity(); + var statusCode = response.getCode(); if (isInvalidStatusCode(statusCode)) { throw getHttpError(response); } try { - String raw = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); + var raw = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); return deserializeOrThrow(raw, JobResponse.class, response.getCode()); } finally { @@ -173,31 +170,31 @@ public TResponse reqGetResult( Class responseClass, String inferenceId ) { - ProductInfo productInfo = getResponseProductInfo(responseClass); - String url = String + var productInfo = getResponseProductInfo(responseClass); + var url = String .format( "%s/products/%s/results/%s", this.mindeeSettings.getBaseUrl(), productInfo.slug(), inferenceId ); - HttpGet get = new HttpGet(url); + var get = new HttpGet(url); if (this.mindeeSettings.getApiKey().isPresent()) { get.setHeader(HttpHeaders.AUTHORIZATION, this.mindeeSettings.getApiKey().get()); } get.setHeader(HttpHeaders.USER_AGENT, getUserAgent()); - try (CloseableHttpClient httpClient = httpClientBuilder.build()) { + try (var httpClient = httpClientBuilder.build()) { return httpClient.execute(get, response -> { - HttpEntity entity = response.getEntity(); - int status = response.getCode(); + var entity = response.getEntity(); + var status = response.getCode(); try { if (isInvalidStatusCode(status)) { throw getHttpError(response); } - String raw = EntityUtils.toString(entity, StandardCharsets.UTF_8); + var raw = EntityUtils.toString(entity, StandardCharsets.UTF_8); return deserializeOrThrow(raw, responseClass, status); } finally { EntityUtils.consumeQuietly(entity); @@ -215,7 +212,7 @@ private MindeeHttpExceptionV2 getHttpError(ClassicHttpResponse response) { ? "" : EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); - ErrorResponse err = mapper.readValue(rawBody, ErrorResponse.class); + var err = mapper.readValue(rawBody, ErrorResponse.class); if (err.getDetail() == null) { err = makeUnknownError(response.getCode()); @@ -230,7 +227,7 @@ private MindeeHttpExceptionV2 getHttpError(ClassicHttpResponse response) { private HttpPost buildHttpPost(String url) { HttpPost post; try { - URIBuilder uriBuilder = new URIBuilder(url); + var uriBuilder = new URIBuilder(url); post = new HttpPost(uriBuilder.build()); } // This exception will never happen because we are providing the URL internally. @@ -254,7 +251,7 @@ private R deserializeOrThrow( if (httpStatus >= 200 && httpStatus < 400) { try { - R model = mapper.readerFor(clazz).readValue(body); + var model = mapper.readerFor(clazz).readValue(body); model.setRawResponse(body); return model; } catch (Exception exception) { diff --git a/src/main/java/com/mindee/v2/parsing/BaseInference.java b/src/main/java/com/mindee/v2/parsing/BaseInference.java index daa22b9fd..9c648e4c6 100644 --- a/src/main/java/com/mindee/v2/parsing/BaseInference.java +++ b/src/main/java/com/mindee/v2/parsing/BaseInference.java @@ -51,7 +51,7 @@ public abstract class BaseInference { protected TResult result; protected String toStringBase() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); joiner .add("Inference") .add("#########") @@ -65,7 +65,7 @@ protected String toStringBase() { @Override public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); joiner.add(toStringBase()).add(result.toString()); return joiner.toString().trim() + "\n"; } diff --git a/src/main/java/com/mindee/v2/parsing/inference/DataSchemaActiveOptions.java b/src/main/java/com/mindee/v2/parsing/inference/DataSchemaActiveOptions.java index 0b3898dde..18c0efcc8 100644 --- a/src/main/java/com/mindee/v2/parsing/inference/DataSchemaActiveOptions.java +++ b/src/main/java/com/mindee/v2/parsing/inference/DataSchemaActiveOptions.java @@ -26,7 +26,7 @@ public boolean getReplace() { @Override public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); return joiner .add("Data Schema") .add("-----------") diff --git a/src/main/java/com/mindee/v2/parsing/inference/InferenceActiveOptions.java b/src/main/java/com/mindee/v2/parsing/inference/InferenceActiveOptions.java index 5ecbdc047..ca67dd41e 100644 --- a/src/main/java/com/mindee/v2/parsing/inference/InferenceActiveOptions.java +++ b/src/main/java/com/mindee/v2/parsing/inference/InferenceActiveOptions.java @@ -74,7 +74,7 @@ public boolean getTextContext() { @Override public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); return joiner .add("Active Options") .add("==============") diff --git a/src/main/java/com/mindee/v2/parsing/inference/InferenceFile.java b/src/main/java/com/mindee/v2/parsing/inference/InferenceFile.java index f8c963601..68201bc38 100644 --- a/src/main/java/com/mindee/v2/parsing/inference/InferenceFile.java +++ b/src/main/java/com/mindee/v2/parsing/inference/InferenceFile.java @@ -43,7 +43,7 @@ public class InferenceFile { public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); joiner .add("File") .add("====") diff --git a/src/main/java/com/mindee/v2/parsing/inference/InferenceJob.java b/src/main/java/com/mindee/v2/parsing/inference/InferenceJob.java index 69c499a4a..9c469945d 100644 --- a/src/main/java/com/mindee/v2/parsing/inference/InferenceJob.java +++ b/src/main/java/com/mindee/v2/parsing/inference/InferenceJob.java @@ -25,7 +25,7 @@ public class InferenceJob { public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); joiner.add("Job").add("===").add(":ID: " + id); return joiner.toString(); } diff --git a/src/main/java/com/mindee/v2/parsing/inference/InferenceModel.java b/src/main/java/com/mindee/v2/parsing/inference/InferenceModel.java index a7ccc9647..edb5ac1c2 100644 --- a/src/main/java/com/mindee/v2/parsing/inference/InferenceModel.java +++ b/src/main/java/com/mindee/v2/parsing/inference/InferenceModel.java @@ -25,7 +25,7 @@ public class InferenceModel { private String id; public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); return joiner.add("Model").add("=====").add(":ID: " + id).toString(); } } diff --git a/src/main/java/com/mindee/v2/parsing/inference/RawText.java b/src/main/java/com/mindee/v2/parsing/inference/RawText.java index ba3b8953a..dc3936d46 100644 --- a/src/main/java/com/mindee/v2/parsing/inference/RawText.java +++ b/src/main/java/com/mindee/v2/parsing/inference/RawText.java @@ -27,7 +27,7 @@ public String toString() { if (pages == null || pages.isEmpty()) { return ""; } - StringJoiner joiner = new StringJoiner("\n\n"); + var joiner = new StringJoiner("\n\n"); for (RawTextPage page : pages) { joiner.add(page.toString()); } diff --git a/src/main/java/com/mindee/v2/parsing/inference/field/InferenceFields.java b/src/main/java/com/mindee/v2/parsing/inference/field/InferenceFields.java index 025e79d89..fa9101ce3 100644 --- a/src/main/java/com/mindee/v2/parsing/inference/field/InferenceFields.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/InferenceFields.java @@ -48,7 +48,7 @@ public String toString(int indent) { if (this.isEmpty()) { return ""; } - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); this.forEach((fieldKey, fieldInstance) -> { StringBuilder strBuilder = new StringBuilder(); diff --git a/src/main/java/com/mindee/v2/parsing/inference/field/ListField.java b/src/main/java/com/mindee/v2/parsing/inference/field/ListField.java index e21030611..adb7395dc 100644 --- a/src/main/java/com/mindee/v2/parsing/inference/field/ListField.java +++ b/src/main/java/com/mindee/v2/parsing/inference/field/ListField.java @@ -65,7 +65,7 @@ public String toString() { if (items == null || items.isEmpty()) { return "\n"; } - StringJoiner joiner = new StringJoiner("\n * "); + var joiner = new StringJoiner("\n * "); joiner.add(""); for (DynamicField item : items) { if (item != null) { diff --git a/src/main/java/com/mindee/v2/product/classification/ClassificationResult.java b/src/main/java/com/mindee/v2/product/classification/ClassificationResult.java index 77ccd1d82..2649bfd68 100644 --- a/src/main/java/com/mindee/v2/product/classification/ClassificationResult.java +++ b/src/main/java/com/mindee/v2/product/classification/ClassificationResult.java @@ -25,7 +25,7 @@ public final class ClassificationResult { @Override public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); joiner.add("Classification\n=============="); joiner.add(classification.toString()); diff --git a/src/main/java/com/mindee/v2/product/crop/CropResult.java b/src/main/java/com/mindee/v2/product/crop/CropResult.java index 7beea3e74..121e3f882 100644 --- a/src/main/java/com/mindee/v2/product/crop/CropResult.java +++ b/src/main/java/com/mindee/v2/product/crop/CropResult.java @@ -26,7 +26,7 @@ public final class CropResult { @Override public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); joiner.add("Crops\n====="); for (CropItem item : crops) { joiner.add(item.toString()); diff --git a/src/main/java/com/mindee/v2/product/extraction/ExtractionInference.java b/src/main/java/com/mindee/v2/product/extraction/ExtractionInference.java index 7a04169a4..62418bfd6 100644 --- a/src/main/java/com/mindee/v2/product/extraction/ExtractionInference.java +++ b/src/main/java/com/mindee/v2/product/extraction/ExtractionInference.java @@ -25,7 +25,7 @@ public class ExtractionInference extends BaseInference { @Override public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); joiner.add(toStringBase()).add(activeOptions.toString()).add("").add(result.toString()); return joiner.toString().trim() + "\n"; } diff --git a/src/main/java/com/mindee/v2/product/extraction/ExtractionResult.java b/src/main/java/com/mindee/v2/product/extraction/ExtractionResult.java index d0709eb70..00cb0e690 100644 --- a/src/main/java/com/mindee/v2/product/extraction/ExtractionResult.java +++ b/src/main/java/com/mindee/v2/product/extraction/ExtractionResult.java @@ -41,7 +41,7 @@ public final class ExtractionResult { @Override public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); joiner.add("Fields").add("======"); joiner.add(fields.toString()); diff --git a/src/main/java/com/mindee/v2/product/ocr/OcrResult.java b/src/main/java/com/mindee/v2/product/ocr/OcrResult.java index 7a5cfc286..a67f34a51 100644 --- a/src/main/java/com/mindee/v2/product/ocr/OcrResult.java +++ b/src/main/java/com/mindee/v2/product/ocr/OcrResult.java @@ -26,7 +26,7 @@ public final class OcrResult { @Override public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); joiner.add("Pages\n======"); for (OcrPage item : pages) { joiner.add(item.toString()); diff --git a/src/main/java/com/mindee/v2/product/split/SplitResult.java b/src/main/java/com/mindee/v2/product/split/SplitResult.java index 41deb8ecc..97c1e65c2 100644 --- a/src/main/java/com/mindee/v2/product/split/SplitResult.java +++ b/src/main/java/com/mindee/v2/product/split/SplitResult.java @@ -26,7 +26,7 @@ public final class SplitResult { @Override public String toString() { - StringJoiner joiner = new StringJoiner("\n"); + var joiner = new StringJoiner("\n"); joiner.add("Splits\n======"); for (SplitRange item : splits) { joiner.add(item.toString()); diff --git a/src/test/java/com/mindee/v1/workflow/WorkflowTest.java b/src/test/java/com/mindee/v1/workflow/WorkflowTest.java index 4c228fbb6..68b623ffc 100644 --- a/src/test/java/com/mindee/v1/workflow/WorkflowTest.java +++ b/src/test/java/com/mindee/v1/workflow/WorkflowTest.java @@ -49,7 +49,7 @@ void sendingADocumentToAnExecutionShouldDeserializeResponseCorrectly() throws IO var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(workflowResponse)); String workflowId = "07ebf237-ff27-4eee-b6a2-425df4a5cca6"; - LocalInputSource inputSource = new LocalInputSource( + var inputSource = new LocalInputSource( getV1ResourcePath("products/financial_document/default_sample.jpg") ); @@ -88,7 +88,7 @@ void sendingADocumentToAnExecutionWithPriorityAndAliasShouldDeserializeResponseC var mindeeClient = new MindeeClient(new FakeMindeeApiV1<>(workflowResponse)); String workflowId = "07ebf237-ff27-4eee-b6a2-425df4a5cca6"; - LocalInputSource inputSource = new LocalInputSource( + var inputSource = new LocalInputSource( getV1ResourcePath("products/financial_document/default_sample.jpg") ); diff --git a/src/test/java/com/mindee/v2/MindeeClientTest.java b/src/test/java/com/mindee/v2/MindeeClientTest.java index b3e5f1da6..9675c9e42 100644 --- a/src/test/java/com/mindee/v2/MindeeClientTest.java +++ b/src/test/java/com/mindee/v2/MindeeClientTest.java @@ -86,7 +86,7 @@ void document_getJob_async() throws JsonProcessingException { JobResponse processing = mapper.readValue(json, JobResponse.class); - MindeeClient mindeeClient = new MindeeClient(new FakeMindeeApiV2(processing, null)); + var mindeeClient = new MindeeClient(new FakeMindeeApiV2(processing, null)); JobResponse response = mindeeClient.getJob("dummy-id"); assertNotNull(response, "getJob() must return a response"); @@ -106,7 +106,7 @@ void document_getResult_async() throws IOException { mapper.findAndRegisterModules(); ExtractionResponse processing = mapper.readValue(json, ExtractionResponse.class); - MindeeClient mindeeClient = new MindeeClient(new FakeMindeeApiV2(null, processing)); + var mindeeClient = new MindeeClient(new FakeMindeeApiV2(null, processing)); ExtractionResponse response = mindeeClient .getResult(ExtractionResponse.class, "12345678-1234-1234-1234-123456789abc");