|
4 | 4 | from mindee.documents.base import Document, TypeDocument |
5 | 5 | from mindee.documents.config import DocumentConfig, DocumentConfigDict |
6 | 6 | from mindee.documents.custom.custom_v1 import CustomV1 |
7 | | -from mindee.documents.financial_document import FinancialDocument |
| 7 | +from mindee.documents.financial.financial_v1 import FinancialV1 |
8 | 8 | from mindee.documents.invoice.invoice_v3 import InvoiceV3 |
9 | 9 | from mindee.documents.passport.passport_v1 import PassportV1 |
10 | 10 | from mindee.documents.receipt.receipt_v3 import ReceiptV3 |
| 11 | +from mindee.documents.receipt.receipt_v4 import ReceiptV4 |
11 | 12 | from mindee.documents.us.bank_check.bank_check_v1 import BankCheckV1 |
12 | 13 | from mindee.endpoints import OTS_OWNER, CustomEndpoint, HTTPException, StandardEndpoint |
13 | 14 | from mindee.input.page_options import PageOptions |
|
22 | 23 | from mindee.response import PredictResponse |
23 | 24 |
|
24 | 25 |
|
25 | | -def get_type_var_name(type_var) -> str: |
| 26 | +def get_bound_classname(type_var) -> str: |
26 | 27 | """Get the name of the bound class.""" |
27 | 28 | return type_var.__bound__.__name__ |
28 | 29 |
|
@@ -62,8 +63,8 @@ def parse( |
62 | 63 | Set to `False` if you need to access the file after this operation. |
63 | 64 | :param page_options: PageOptions object for cutting multipage documents. |
64 | 65 | """ |
65 | | - if get_type_var_name(document_class) != CustomV1.__name__: |
66 | | - endpoint_name = get_type_var_name(document_class) |
| 66 | + if get_bound_classname(document_class) != CustomV1.__name__: |
| 67 | + endpoint_name = get_bound_classname(document_class) |
67 | 68 | elif endpoint_name is None: |
68 | 69 | raise RuntimeError("document_type is required for CustomDocument") |
69 | 70 |
|
@@ -109,7 +110,7 @@ def _make_request( |
109 | 110 | include_words: bool, |
110 | 111 | close_file: bool, |
111 | 112 | ) -> PredictResponse[TypeDocument]: |
112 | | - if get_type_var_name(document_class) != doc_config.document_class.__name__: |
| 113 | + if get_bound_classname(document_class) != doc_config.document_class.__name__: |
113 | 114 | raise RuntimeError("Document class mismatch!") |
114 | 115 |
|
115 | 116 | response = doc_config.document_class.request( |
@@ -181,9 +182,18 @@ def _init_default_endpoints(self) -> None: |
181 | 182 | ) |
182 | 183 | ], |
183 | 184 | ), |
184 | | - (OTS_OWNER, FinancialDocument.__name__): DocumentConfig( |
| 185 | + (OTS_OWNER, ReceiptV4.__name__): DocumentConfig( |
| 186 | + document_type="receipt_v3", |
| 187 | + document_class=ReceiptV4, |
| 188 | + endpoints=[ |
| 189 | + StandardEndpoint( |
| 190 | + url_name="expense_receipts", version="4", api_key=self.api_key |
| 191 | + ) |
| 192 | + ], |
| 193 | + ), |
| 194 | + (OTS_OWNER, FinancialV1.__name__): DocumentConfig( |
185 | 195 | document_type="financial_doc", |
186 | | - document_class=FinancialDocument, |
| 196 | + document_class=FinancialV1, |
187 | 197 | endpoints=[ |
188 | 198 | StandardEndpoint( |
189 | 199 | url_name="invoices", version="3", api_key=self.api_key |
|
0 commit comments